Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
April 25, 2017
arrowPress Releases

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

Opinion: Why You Might Want To Consider Java And/Or Clojure For Your Next Project
Opinion: Why You Might Want To Consider Java And/Or Clojure For Your Next Project
July 7, 2011 | By Gavan Woolery

[Though Java might initially come off as a mediocre language, Appstream CTO Gavan Woolery argues that it has advantages you might want to consider for your next project, in this #altdevblogaday-reprinted opinion piece.]

First, let's be clear: I am speaking to anyone but console/mobile/AAA developers here.

I like to program 'close to the metal.' It gives me a feeling of control, even if the compiler is actually completely rewiring my code. I like C and C++ because they do not try to hide much from the programmer they are very basic imperative languages. That said, there are many, many things I hate about them.

For a long time, Java struck me as a somewhat mediocre language. Its performance seemed a little bit weak and most people would scoff at the concept of using it for game programming.

More recent versions of the JVM actually have great performance. It can be difficult to organize an effective benchmark, but some tests suggest that Java can actually exceed the speed of C/C++ in certain cases. This is due in part to the fact that Java has more constraints in some areas (i.e. pointers), and that it can be optimized more effectively based on this.

Java can also optimize itself with JIT compilation, and optimize between successive runs. That said, you definitely should not choose Java on the basis of performance alone.

I once heard something that has stuck in my mind ever since: "servers are cheap, programmers are expensive." In other words, you have to carefully choose your battles: at what point is optimization worth a programmer's sanity? Java might not be the fastest language, but it will keep you slightly more sane than C/C++, and is usually worth the slight performance penalty.

But what is really important is that the loss of performance can be a good thing. When you stop focusing on performance, and start focusing more on your game, a new world of opportunity opens up.

I hate to always bring it up in examples, but take a look at Minecraft: simple graphics, but it runs on a variety of hardware and operating systems. Java programs have better potential for a long lifespan this might not seem too important, but try launching an old DOS game these days can be quite tricky sometimes, even with an emulator.

Java is also cross-platform this makes porting really painless. You can also run Java in the browser as an applet or via a quick-launcher. Managing 'imports' and 'packages' is much easier than dealing with '#include' statements in large projects.

You can also easily get a free IDE up and running quickly: Eclipse (for C/C++, last I checked, setting up the compiler could be tricky on Windows, which does not include a compiler by default like gcc on Mac/Linux). 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.

I am no expert on how well Java interfaces with DLLs and what the performance penalty is for accessing the GPU from Java. I also do not recall how Java handles passing resources to the GPU, which are usually passed via pointers. But it is fast enough to generate simplistic graphics at the very least (see: JOGL, JMonkey Engine, LWJGL, etc). While WebGL and Javascript can do the same, Javascript is not quite at the performance level of Java (even with V8 and the like), and as a language it is not the best designed for taking on larger projects.

Clojure is another language you might want to examine. It is a relatively new functional language that compiles to the JVM, and is a LISP dialect. It imposes certain restrictions (i.e. state-based immutable data) to make multithreading as simple and painless as possible. As the number of cores on a CPU increase, I could see Clojure being a real contender, although I am still slightly skeptical of its performance in some areas.

TL;DR: sacrificing performance can be a hard pill to swallow but it is also very liberating to not worry about it so much and focus on making something simple and easy to code.

[This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]

Related Jobs

Wevr — Venice, California, United States

Generalist Engineer
Wavedash Games
Wavedash Games — Oakland, California, United States

Gameplay Engineer
Sony PlayStation
Sony PlayStation — San Mateo, California, United States

Sr. Staff Programmer- VR
DigiPen Institute of Technology Singapore
DigiPen Institute of Technology Singapore — Singapore, Singapore

Senior Lecturer

Loading Comments

loader image