Why You Might Want To Consider Java And/Or Clojure For Your Next Project
gamasutra.com
gamasutra.com
C# actually is quite good in many ways as well, but
unfortunately its open source counterpart (Mono) leaves
it trailing a little bit behind on operating systems
other than Windows.
This is just an uninformed opinion. Mono is just better for desktop applications and games, in all ways that count.Performance wise, Mono is much more predictable. The VM starts faster and doesn't need special warmup. If you don't like the VM, you can always compile ahead-of-time. It has stack-allocated values, unsigned integers and if you're inclined you can always come up with your own special 256-bit integers that are still stack allocated.
I wrote lots of data processing scripts this last year and Mono had better performance characteristics than Java. And that's before I tried plugging in Mono.SIMD which totally blew me away.
Writing bindings to C/C++ libraries using P/Invoke is a piece of cake. That's because Mono has richer primitives; in "unsafe" blocks of code you can even have pointers and pointer arithmetic.
For desktop apps you can create native interfaces with GTK+ on Gnome, Windows Forms / WPF on Windows and Cocoa on OS X. I mean, the bindings for GTK and Cocoa are state of the art as far as bindings go and on Windows .NET is just native.
And some people scoff at the idea of building a specific interface for each platform, but I never seen a Java desktop application that I haven't found nauseating. Qt Jambi is the only hope you have for something decent, but kind of sucks on OS X.
It isn't a BAD choice, but if I were an indie dev, I would look at something like Torque2D or Torque3D, especially since those give you a nice set of tools as well as a way to move to iPhone and consoles.
Also, if you want to get something off the ground fast, check out Corona from Ansca Mobile or even something like the LOVE 2D engine, between the two you can write your game in Lua, which is an awesome little language to write games in.
There is also the option of HTML5 and JS if one were so inclined. Given that everything seems to support HTML5 and JS now, once hardware catches up in the next 2-3 years, that might be an interesting option for game dev across all platforms.
Oh, and if you are going to do a 3D game, start with a good 3D engine and toolset, otherwise you'll spend all your time building an engine instead of building a game.
I miss the Kanji game engine. It was bought by Gogii and then never re-released for developer licensing.
But then, why Java? Why not a language that's even more high-level (like Python, Lua, or Haskell)?
At a contracting gig I had, one of the Java guys gave us a talk about Scala. And OH MY GOD SCALA HAS MAPS and OH MY GOD SCALA ALLOWS FUNCTIONAL ITERATION OVER LISTS. It was like his entire relationship to programming had changed, and he had to tell the world.
I felt for the guy - he was clearly pretty excited about this - and it must have been like a breath of fresh air for him. The talk didn't go down that well though, as it was to the Perl team...
1) It is very well established and widely distributed. 2) It is old enough to have been battle-hardened, but new enough to contain some useful paradigms/features. It also has support for higher level languages like Clojure and Scala. 3) It is a good balance between performance and ease of use. 4) It has many libraries and resources. 5) While I am urging to give performance some slack, that does not mean to ignore it completely. Because Java is imperative, it gives programmers slightly better control of their algorithms. Most graphics programmers prefer to work low-level, at least in the core of their engine. Python and similar languages are often integrated into script engines, but rarely used for the core of an engine. I am suggesting Java because it allows programmers to work in at least a somewhat low-level style (the byte code is semi-predictable). 6) It is pretty easy to get started and learn (not necessarily easy to master though).
I chose Clojure because it is Java-compatible, but Scala is probably just as good a choice.
I personally don't know anything about Haskell, but I have heard that it has a very complicated performance model. I.e., it's hard to predict what will be fast and what will be slow, and if something is slow that seems like it ought to be fast, it can be hard to figure out how to fix it. (Since that was one of the major complaints of Haskell users the last time I seriously considered learning Haskell, it might be fixed or mitigated by now.)
Scala can also be slow or unpredictable when using functional idioms, but with Scala you can always revert to Java-style programming to get Java-level performance. The fact that you can do that for a single function or even a single inner loop in a code file that is mostly nice clean functional code is very convenient. One thing I hated about Jython was rewriting entire classes in Java when only a little part was performance-sensitive. Or, equally frustrating, having a Jython class whose associated "little" classes (performance-sensitive callbacks such as renderers) were in a completely different place in the source tree because they were implemented in Java.
Well, if you're targeting mobile, and by 'mobile' you include Android, you already have to use Java. You could use Clojure in this case as well, but Clojure in my experience is too inconvenient on Android to be worth it (yet.)
I think he is just referring to iOS. However I have to disagree the author that it's suitable for desktop GUI applications. I hate running Java programs on desktops (may be except Eclipse), as they always take much more resources than they actually needs, while still maintaining ugly interfaces all over different platforms, or would require much more work for the developers to solve issues with incompatibilities over different configurations of Java installs. For GUIs, Java is _still_ (for since Swing was available) not the choice.
What did you dislike about it? App scaffolding? Compiling? Deployment? Use of Java libraries inside Clojure?
The other issue I ran into was that there were issues in getting Clojure to interact with Android properly. Android requires that you compile your code into classes which means you will have to use :genclass in Clojure and implement a lot of interfaces. This in itself isn't that much of a problem (it will make you code less Lispy but oh well) but when I tried it there were bugs in Clojure which made it impossible for me to do some things on Android that I would have liked. That part of the language runtime is a little immature in my experience.
I wouldn't give up based on my words though. It may have improved since I last tried. If you want to look someplace for info on how to get started, I found that this fellow has a lot to offer: http://www.deepbluelambda.org/programming/clojure/creating-a...
I've seen toy Clojure apps running on Android 2.2 and they took sensibly less than 5-10 seconds to load. I'm mentioning this since parent doesn't specify which Android version he was using, and JIT compiling was only recently introduced in 2.2.
Immutable vectors - loads of temporary heap objects
Mutable vectors - spaghetti data flow
Implicitly grouped primitives - horrible verbosity and repetition
And of course, there's no operator overloading.
There are potential solutions to this that could be implemented at the language level e.g. stack objects or macros that expand to primitives at compile time, but none of the other mature JVM languages seem to do any better at it.
Say what you will about C++, but it lets you write code like this:
vec4 lerp(vec4 a, vec4 b, float s) {
return a + s*(b - a)
}
that compiles to something efficient. With all the vector math that ends up in my game code, I just couldn't live without this.http://altdevblogaday.com/2011/07/06/why-you-might-want-to-c...
I am using Clojure & Slick2d for the Action RPG I am developing so I can say Clojure is a great choice for games!
I even open sourced my game: (with video) https://code.google.com/p/clojure-rpg/
You can play it here (older version , not so fun but works!) http://resatori.com/cyber-dungeon-quest-alpha-1