Why do you use Java for games?

So, I have been arguing with 2 persons AT LEAST a year from now, about using Java for game development. They mainly code in C++, or at least don’t use Java for games, and they just keep bothering me saying that “Java sucks for making games”.

I mean, OK, most of what I see online or talking around is that Java is, in general, “slower” than other languages and therefore, “games made with Java are slower”.

But I’m tired of them. I like Java, it was and still is the first language I learned. I also learned how to use jME about 2 years ago and I’m still using it despite what everyone says. I really don’t think Java is the worst option for creating games.

But I want to know your opinion, guys. This is not a topic discussing if you should use Java or not. It’s just a discussion of why you use it. (And ,optional, how you handle those pain in the ***es that say C++ is the master race).

1 Like

I come from a background that includes assembler, hard-core C, C++, etc… I still prefer to use Java. My experience on many projects has been that we can develop an app in Java in the same amount of time it takes to debug the memory issues of an equivalent app in C++. Team sizes tend to be 1.5 to 2x as large, the open source ecosystem for C++ is much worse, etc…

And for my, C++ is an abysmally designed language. It’s needlessly obtuse and regular day-to-day coding tends to obfuscate itself over time.

I’m willing to take whatever performance hit might or might not exist because I will get more done in the same amount of time.

Anecdotally, I once converted a C version of a microwave propagation algorithm based on a least-squares-fit. It would fan out radials to build a 2d grid of bins containing falloff values, etc… I’d already heavily optimized the C version when I chose to rewrite it in Java. This was in 1998(?) or so, +/- 1 year. The Java version was not as fast but was not too far off. What it lost in to-the-metal FP performance it gained back with hotspot and so on… it was still slower.

However, over the years I had a lot of fun taking that out once a year or so and just rerunning both versions… same exe, same class files. It was fun to watch Java catch up and pass it over the years. Probably if I’d ever recompiled the C version with new processor settings and so on it would have kept up… but I didn’t have to do that with Java. Runtime optimization was winning that battle for me.

But anyway, plenty of people still makes games in Javascript and flash. And if you want raw performance, nothing beats hand optimized assembly language if you have the time. I say put your time where it’s most valuable.


I use Java as my de facto programming language for all my projects for several reasons:

  • Java is fast and intuitive to develop in. I find it strikes a syntactic and semantic sweet spot - it’s verbose enough that it’s easy to see what’s happening on any given line, but unlike C++ the language is not so horribly complicated that seeing what a line of code is doing is usually fairly easy. If you write clean and simple C++ this isn’t always an issue, but having worked with both I find Java to hit a nice balance that C++ simply does not have. In short: Java is fast and straightforward to develop in. C++ usually isn’t.

  • Java’s ecosystem of libraries and tools is worlds beyond C++'s. If you want to do something in Java, odds are there is at least one excellent and open source library/tool for you (in many cases, 2, 3, or even more excellent choices). C++ is much more hit-and-miss, at least in my experience. The only place where I’ve found Java to suffer slightly is if you want to embed Python, Lua, or some other similar scripting language in your project. In C++ that’s straightforward, in Java usually you have to (a) accept an alternative instead, or (b) go to some pain and hassle to interface with native code.

  • Java is painlessly cross platform. 99.999% of the time you develop against one API, compile and package once, and your code will run on any major platform. Mobile complicates this slightly since Android APIs haven’t historically tracked the most recent version of the JDK, but even that is starting to change with some of the newer Android versions. iOS is much more problematic, but it’s problematic for anyone who wants to write cross-platform code that runs on iOS. Of course, the compile-once-run-anywhere benefit is a little harder when you have code that depends on native code (like jME), but once you have builds of your native libraries you’re back to good ol’ cross-platform Java. C++ usually isn’t nearly this painless.

  • Java is dramatically easier to debug. Unless you’re calling into a native library that crashes the JVM (usually very rare), any problems you encounter result in a beautiful stack trace with no extra effort on your part. 99% of my debugging consists of looking at a stack trace (which is usually enough to find the bug), and maybe recompiling with a few System.out.println() calls in strategic places. C++ doesn’t give you a stack trace - when you’re debugging you’re on your own.

  • Java gives you fast memory management - for free. Any C/C++ programmer will tell you that memory management is notoriously hard to get right. Even “correct” memory management sometimes results in nastiness due to heap fragmentation - something that’s extremely hard to guard against in native code, but something that Java’s compacting garbage collectors give you for free. True, sometimes you do have to deal with occasional pauses for the GC, but in practice the severity of this seems dramatically overstated by native programmers. Java’s new object allocation takes a significantly shorter code path than C++'s, and the memory is already reserved for the VM - no call to the OS for new memory. In amortized time, Java programs should be faster, on average, in terms of memory allocation/freeing than C++ programs. Runtime performance aside, you simply don’t need to worry about one of the hardest aspects of C++ programming - getting memory management right.

  • Java is far faster than most people give it credit for being. With modern JVM’s, Java code is usually within a 1 - 2x performance factor when compared to C++ code, and the hit is usually only significant when dealing with lots of number crunching. For the huge majority of applications, this is fast enough to not be a difference that’s even remotely noticeable, and the huge majority of applications don’t do much number crunching at all.

In short: Java is a pleasure to work with. You often spend far less time for the same result, and it comes with a whole host of benefits, such as compile-once-run-anywhere that C++ can’t touch. It’ll be even better when JDK 9 is out and you can easily distribute a custom, minimal JRE for your application.

As far as your C++ friends go… they can’t really know that “Java sucks for making games” if they haven’t tried it. If anything, given how difficult and tedious development with C++ is, I’d tell them that C++ sucks for making games. :wink:

As far as the “Java is slow” crowd goes, take everything you read on the subject online with a MAJOR grain of salt. I see a lot of discussions on the subject by people who, to put it bluntly, have little idea what they’re talking about. Even when you get down to good numbers (which in itself is hard to do when you have a JIT optimizing the code on the fly), the majority of the time the difference in performance is either (a) negligible, or (b) just doesn’t matter.


Java is awesome for back-end server development. It’s what we use in our studio for our games. Not only is it easier to iterate through features and bug-fixes, but the JVM itself provides incredible insight for resolving memory leaks and thread performance issues.

pspeed and danielp have already pointed to very solid reasons to use Java.

If you want a list of past games that use Java… google around… they’re everywhere. Here’s a list some others have started compiling: http://www.java-gaming.org/index.php?topic=3123.0

It’s far from complete… but a good start when combating naysayers.

1 Like

I haven’t got the experience as others here but I have same reasons as pspeed. I’m more interested in learning good programming skills than finishing a high quality game. I think jME3 is a great learning resource. After reading some books about API Design I noticed that java is much cleaner than c++. I’ve written some bigger software in c++ but I really didn’t like how the source code looked like.

And I don’t need the performance boost of C++. I haven’t got the time to wrtie an AAA game on my own and therefore won’t get performance issues. I think everything what I want and am able to do is achievable with jME3 and the otherthings are beyond my scope.

1 Like

C++ legacy can make dramatic impact on what to pick for new project. I mean those guys might have HUGE code base of their own, so their new projects might be assembled from relatively large parts with some tweaking, which is a completely different story from when you start a new project from scratch. Besides Stroustrup did a lot of improvements considering, in particular, memory management (smart pointers etc), Java is just a next generation language, not something that was pulled to modern development standards artificially. All depends of context, in some areas there’s no still alternative to assembler, but speaking of modern games… if you start from level that’s that low, you simply won’t finish it, most likely. Plus, yeah, as said, syntax difference makes working on Java pleasure, if you compare that to cpp.


Where is the bottleneck of modern games (I mean big fat games like the ones your friends are probably think about).?
IMHO on the GPU…
Whatever happens, whatever language you use, if you are a fairly decent developer, your CPU is gonna spend its time waiting for your GPU to do its stuff… So be nice to it and at least give it something nice like java to run and not this infamous C++.

But let’s say that the CPU is the bottleneck…
There are so many reasons for a program to be slow - the developer’s skills being the main one - that it’s very unlikely that the bottleneck of your game will ever be the language you used…

So why bother? Just use le language you know, and like, and do your best… it just happens that this language is Java for people around here, if it’s C++ for your friends… so be it… I really doubt it will make any difference.


Well if you make closed source sw you usually compile for a generic processor and on top of that in a game heavier things apart from physics are usually things that can and should be executed on gpu… so this “Giava nut gud for games” makes little sense.


Well I use java, because I started way before unity (actually jme kinda ensured that I now have a fulltime job as java developer for business software)

  • I do not care if performance is 10,20 or even 200% worse than in C, I still get a solid 100fps+ in my game, and who cares about more?

  • I do care about not having to endlessy debug around shitty compilers that work different on any system, or not at all

  • I do not care about 32 or 64 bit, and compiling for every bullshit architecture. If lwjgl works (or jogl2) jme works.

  • I actually like to programm microcontrollers, as they are simple and direct, however modern C development is thanks to the os, all but that. If i cannot go bare metal, I prefer actually working abstractions

  • I dislike, that eve only one small memory issue, like a wild pointer, can lead to absolutly ANY possible behaviour, depending on what bits are flipped, I have no gurantee whatsoever in error cases. (as they are undefined by specification due to performance gains)

  • I actually like to use powerfull debuggers, only a few exist for C

  • Java has Reflection and Annotations, both are concepts not possible in C without mayor pains

  • If I actually have one algorithm that need to be really fast, why go C? if you can go OpenCL for it, directly from jme.

  • It does not matter what the engine can do, in small projects you are always bound by time and money, so no engine and performance is actually helping you, however a language that safes you time while developing does reduce those constraints. (Be honest, noone here is to develop the next Crysis, where the 10% C performance improvement will make the difference between lagging and running good)

  • If you use crap algorihms, no language is saving you. E.g. if you have a O(n^2) algorithm, a 10 times faster computer is only giving you 3 times the performance. If you need longer to code in a language, and can debug it worse, you will refrain from useing more complex but better scaling algorithms. A 50% slower language, but an algorithm that turns above into a O(log(n)) will win anytime. Sure you could do that better algorithm in C, but as I said time is fairly limited.

  • Since you are not gonna compete on grafics, you need to compete on gameplay. There is a lot of rather ugly not so good performing games out there that have huge fanbases. E.g. Terraria is running with less fps on my machine than Battlefield, do I care? Nah as long as its ~60+ I don’t.

  • In java memory management is actually cheaper than in C, as malloc and free need to be synchronized over all cores, while java has a queue for each thread, and only needs to sync on it running dry. new is practically without cost!
    And that is why most C applications use a own memory allocator, that for example allocates a huge chunk and manages it internally. What a fun thing to implement, I totally wanna do that …

*Last but not least, In c there are like a million ways, using a third party library is gonna bite you in the ass due to stuff like different pointer concepts, unchecked casts, ect. In java it is pretty straight forward.

tl;dr Games running slow are often a result of using inferior algorithms, or bad system design, In both cases rapid iterations help, and Java allows this way more than C languages can. (If you design a language for maximum performance, you will loose greatly at compile time (and I’m talking seconds vs. half an hour here))

Anyway, even with a steaming pile of garbage (minecraft, the code is really inefficient in many places) you can make millions, so why care that it might not be the best?


Java has been the first language I learned, and it will probably be the only language I will use to make PC games. I tried learning C / C++ for when I need to do more hardware specific programs, and let me just say this: I HATE IT. But rather than give such an absolute answer as that, let me go through my reasons why:

  1. It is so much quicker and easier to get a working program running. Have you seen the code required to get just a blank window to show in C++, let alone do anything useful with it??? It’s insane! In java I can write three lines of code to do the same things as like…50 in C++! Also, for my 8 bit game console, I’m writing an emulator for it in Java, but the video core that will run on the actual hardware I have to do in C. It’s taken me about an hour to get the emulated VC working in the emulator, but days to figure out how to get the dev tools to work, and more days just initialize the STM32 correctly in C.

2)I don’t have to worry about memory management, Java takes care of it for me! Now it probably isn’t the best out there, or most likely that’s just me doing something horribly wrong that’s making a memory leak. But having to manually manage my memory usage in C is just…no.

3)I have yet to encounter a point to where Java itself was bottlenecking my game. Well actually that’s not true, I found one instance. But that’s beside the point! 99% of the time, my games slow down because I’m putting too much load on my GPU. My CPU barely has to do anything.

4)I don’t like how C needs two files to make a class or whatever it’s called. And the import system is way too confusing. What do you mean I have to have a .h file for every .c file? Why can’t it just be in one file like in Java!

5)They keep changing very basic functions!!! If someone suggests one thing, I try it and it doesn’t compile so I look for something else, but then that doesn’t compile and then I learn that the compiler set I use doesn’t support that function so I need to get an entirely new compiler set, so that’s when I just give up and create a very lengthy and non optimized algorithm that could’ve been done in one line of code!

6)I like the whole object oriented approach.

Now Java has it’s quirks, but I’ve learned to get over them. There is no “superior master race language that beats all others” with the exception of assembly, you can’t get any more performance out of that, but even ASM has it’s drawbacks coughwaytoomuchtokeepaftercough but mainly it’s preference. Now there are some situations where you don’t have much of a choice, since you can’t run Java on an STM32 or Z80, and some languages have their place better than others, I just choose to stick with Java because that’s what I’m good at.


I suppose it’s because the games I make don’t need low level speed and I don’t push hardware to the max.

It’s easy to do because it’s a hobby and I can rely on the garbage collector rather than worrying about memory management and pointers etc.

More time programming and having fun and less time debugging.

If I was writing a AAA game that pushed hardware and language capabilities to the max. I’d do a lower level language.

I don’t need to.

And of course there’s Android.


How computers are right now it makes little difference if a game is made with wither Java, C++/C# or even Python, specially on the indie side of things. The difference actually lies in the skill of the programmers and how optimized the assets are. C++ should be considered more when you have a very ambitious game and you have a large or very skilled team, otherwise it becomes a waste of time when you can do the same work on other languages faster.

To be honest I chose Java for convenience. It offers the most benefits with less headaches for a single developer.

  • Python is very useful since you have both OOP and Functional programming, but the platforms you can release on is very limited at the moment (PC only in a reliable way, Android is getting there but not very good last time I checked).
  • C# is a very good language too but there was no good open source engine that allows multiplatform without paying a license. and don’t get me started with Unity…
  • There is one fully featured, open source C++ game engine that I like, but I am a lazy person and I don’t want to use CMake and other apps when I can do the same with Java and less tools.

Well for me it’s simple. I learned Java as my first serious programming language… and haven’t taken time to properly learn anything else yet.
I love the benefits of Java described above though :smile:

1 Like

Managed languages are the future. Period. the 70s want their crappy manual memory management back (C/C++). We even knew that back then (Lisp!).

There is a case for C in systems programming… but otherwise. That stuff is good for one thing. Even more over budget over time death march projects.

Now having said that. I need to consider Unreal for my next project. Why? cus Console support. Unity has C#, but it is a nerfed old version than still have problems because its back end is C++.

For us, indie devs, if you think you need the performance of C++, your doing it wrong. And its probably still about 5x easier to just make it mulitthreaded in java anyway.


I agree. No console support is the only thing that is not goid with jme. Otherwise I can’t find any other reason why would someone used to jme want to switch.

1 Like

actually i remeber even back then games were written in lisp, I saw 1-2 of them a few month ago when I made a retro gaming station based on an old win95 laptop.

1 Like

currently one of the fasted and most scale-able graph based big data solutions is all in lisp. the catch with lisp is that good run times are not so cheap.

1 Like

And want to add that, with new Parallel Stream API in Java 8 it is even more easier to do multithreading.
This can fit in Entity System structure (or wherever you are processing a list when operations are independent) you can simply switch your foreach() loop on entity set with a parallel foreach(). (providing that you are meeting the requirements Stream Parallel Guidance)

1 Like

My first language was Basic later it was Pascal and Oberon. In university it was C/C++ and I liked it very much. My first job I dealed with C and still today I do C/C++. With JME I started to learn Java and love it. Javas ecosystem is so big compared to C/C++ that I don’t see a reason to do games in C/C++. But for me computer languages are not the most important thing. I would also hack games in Lua if I could and I tried with Polycode but JME was much easier much more straightforward so I guess I stick with Java :smile:

1 Like

I really don’t have anything to add to what pspeed said.
Go with what makes you productive and you have fun with.

1 Like