Has anyone attempted to use Scala (or something similar technically like Groovy, Clojure, etc.) to build a game? Inside these languages, have you attempted to use some of the better-known game libraries already available for Java? Aside from syntax sugar, simplicity and brevity, are there any distinct advantages to using these alternative languages?
They all could be used for game development but beyond a few simple examples I don’t know of anyone using Scala or Clojure in game development - I am not familar with groovy at all.
Pulpcore, in version 0.11.3, included some initial support for Scalas’ more advanced features but I have not personally had a play with it and am not sure on its current status. As all the languages mentioned can call into Java libraries with ease you should be able to use any java game library but the api will have a java look rather than being idiomatic to the language you are using.
One thing to bear in mind when using some of these languages (Scala and Clojure) is that the IDE support is a fair way behind Java and this can lead to some frustration when coding.
I have programmed in Scala a reasonable amount for non game stuff and quite enjoy it.
Scala is good for small games because you can use ProGuard on Scala applets! Internally, Scala doesn’t require reflection or a runtime library - there is a library, but ProGuard takes out the stuff you don’t use. There was a 4K Scala game last year.
Groovy requires a runtime to handle the dynamic typing and whatever else. I assume Clojure is the same. Perhaps when HotSpot’s invokedynamic bytecode gets in, this will change.
As for advantages, well really it’s just your personal preference (although I’ve seen plenty of Java code where functional programming would help clean things up, IMHO)
I really appreciate the input. Scala and Groovy look very interesting in general, even outside of game programming. The point about the current state of game libraries available for Java will most likely keep me where I’m at now.
Also, brackeen… PulpCore is spectacular, thanks for your effort on that. I’m sure many people appreciate it (I know I do).
Personally I’d go with Scala at the moment. Clojure looks real nice (Lisp on the JVM is a seriously awesome thing), but it’s not quite as popular, which means less support, more bugs, less documentation, etc. And Groovy also has a lot going for it, but from what I’ve heard (never used it myself), it’s incredibly slow, by a factor of 10 or so when compared to Scala (which, IIRC, suffers roughly a 50% speed penalty vs. Java).
Integration with existing libraries shouldn’t be much of an issue at all with any of these - interop with existing Java code is one of the primary concerns in all three of these projects (if you didn’t care about that, there would be little point in using Clojure over plain old Lisp).
PaulReeves is definitely right, though, the crappy IDE support for Scala has caused me quite a few headaches (the plugins for all these languages are very young and at least on my machine cause some extreme instabilities), so bear that in mind. Personally, though I would love to switch almost all of my coding over to Scala for the improved language features, I can’t justify it yet because the productivity gains from the language are almost exactly offset by losses due to the environment (crashes are the biggest problem for me, though the reduced functionality is a bit irritating as well). Maybe once things get a little more stable I’ll finally jump, but it’s still too close for me to feel comfortable yet. That said, I’m hearing good things about IntelliJ’s Scala support, but on my machine the plugin still doesn’t work at all, so YMMV…
I was doing some (very)micro-benchmarking at the weekend and my results was that Groovy was ‘only’ 4x slower that straight Java code (compared to 100x for JRuby, :o which is so obscenely high I suspect I’m doing something very wrong).
It was a single very small, specific benchmark though, so I wouldn’t take those numbers as a general case.
Runs on the JVM. I have a suspended project to get it running on my PocketPC (on top of J9), because I can’t find any functional language which has a Windows Mobile runtime.
I am trying to start a thread where we write about different scripting technologies. If you have any experience about a language, please write a few lines:’’
These things you say could be useful, especially if they all are collected in a single place.