Original Post
Hello,
I've been a gamedev.net forum reader for years, but never registered or posted a message until today. I don't know what changed about today. Oh well.
I've seen a lot of questions/comments about whether Java is suitable for creating commercial games. I wanted to make a comment about that.
We have written a commercial quality action orientated 3d game in Java (about 100,000 lines of code). The underlying proprietary game engine is in c++, but all the game code is in Java (using JNI to implement the engine interface). It was an interesting excersize, and this is what I learned:
1) They're was no material performance penalty for writing the game code in Java. I know this because we happened to have c++ and java versions of the same game side by side, and saw no real difference (maybe 1-5% slower for Java). This was with the latest version of Java and HotSpot. We also used the 'Jet' Java optimizing compiler, but didn't see any real improvement in FPS with Jet over just using hotspot, but it did allow us to have a distributable that didn't require the Java runtime.
2) Be careful with GC. Creating lots of small objects per frame like vectors, matrices and strings will cause noticable GC hits to the game, no matter how you tweak the gc methods or parameters. Fortunately, it turns out that it's pretty easy to avoid GC'ing at all. (if someone's interested i can explain how)
3) Coding is noticibly speedier in Java than in c++. I attribute the speed up to:
a) having one source file per class (as opposed to maintaining a .h and .cpp for c++).
b) The Idea IDE by IntelliJ (which we used for development) because of:
1) Autocompletion/function parameter prompting that actually works ALL THE TIME. (Visual C++ people know what I'm talking about)
2) Massive/Insane refactoring capability like I have never seen before in my life. I develop iteratively, constantly shuffling around classes, renaming, creating new classes, relocating variables, rearanging class hierarchies etc. The refactoring capability in the Idea IDE did it all automatically. Stunning.
(I know all this is the IDE, not Java, but my belief is Java makes this possible. Its much harder for an IDE to do this with c++)
Finally
The Java version of our game worked fine, but we ended up not using the Java version because of a number of reasons:
1) We became an authorized XBox developer, and so had to consider porting to the XBox.
2) The Java language tends to be a bit too simplistic for my tastes. I like enums, multiple inheritance, default parameters, templates, preprocessor directives etc.
(an aside: multiple inheritence with virtual base classes is one of the most wonderful things to facilitate code reuse I've ever seen.)
3) Maintaining the engine interface through the JNI got to be a pain. Nothing wrong with JNI (in fact it performed a LOT faster than I expected), it was just because it was yet another layer.
Anyways, this wasn't to promote Java or anything. In fact I've been an asm,c,c++ programmer for the past 30 years (over 1.5 mil lines of code written). But I did enjoy writing in Java and wanted to share my experience.
My appologies if this is a tired topic.
Thanks
[edited by - imbro on May 1, 2004 11:55:51 AM]