Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Developing in Android is going to be different for me, having spent the last 10 years coding games in C++. What's the main differences / pitfalls / bottlenecks to developing for the Android? My big worry is moving to Java, what am I going to miss most?

To be clearer: what would I miss if I coded the whole thing in Java compared to the way I normally code C++ for consoles?

share|improve this question
Title could be a bit better. Just to be clear are you asking "What is the difference between C++ and Java on the Android Phone?" – Noctrine Aug 17 '10 at 13:22
I think if you use the NDK ( then you can write most of your code in C++. – Chris Howe Aug 17 '10 at 13:59
up vote 6 down vote accepted

The single biggest thing that you'd probably miss would be explicit memory management. On the plus side, Java has run-time type information and real generics. Also see: for some tips from Google on how to keep your Java code efficient.

Raymond Chen has recently been venting about garbage collection and memory management in the CLR and his blog posts are great for understanding how it works. (I know the following links are for the CLR, but they're still relevant for Java development). See especially: and

That being said, there isn't that much difference between Java and C++, and as Chris pointed out, you can code in C/C++ on Android using the NDK.

share|improve this answer
thanks, "you can code in C/C++ on Android using the NDK", yeah I appreciate that, but why stick to old guns all the time if something actually turns out projects better / faster. – Richard Fabian Aug 17 '10 at 15:08
Oh, I see what you're getting at. Java has the bonus of having a massive standard library and an extremely competent library for dealing with XML. The Android platform extends the standard library with libraries for all of the fancy hardware goodies and some extra, user-side functionality. Java also supports incremental compilation/error checking, so you'll get feedback on errors pretty much as soon as you type them. Honestly, you shouldn't fear performance either. It's not going to be as fast as C on bare metal, but it's still quite speedy. I would say that there isn't much to worry about. – brett Aug 17 '10 at 15:17

Google's Chris Pruett talked about writing real-time games for android in Google I/O 2009 and again in 2010. He talks about Java performance on Android among other topics. He also made a game, Replica Island, in Java and you can download the source code to get an idea of how an Android Java game might look like. His blog about the game also has several insightful articles.

The typical pitfalls are similar to those of writing in other garbage collected languages, you use a object pools and allocate stuff in advance to avoid having the GC run when you don't want it to. Methods are virtual by default in Java and it helps to mark them as final when you don't need to override them. The Android Eclipse plugin comes with some neat tools to help you profile your application and monitor heap allocations.

share|improve this answer

You are worrying too much. The API for OpenGL in Android, OpenGL-ES, was deliberately kept C-like. See the OpenGL specs at for details.

It is even possible that you won't miss much of anything from C++. A lot of developers, even the famous programming author Bruce Eckel ('Thinking in C++', 'Thinking in Java'), have found Java a much more effective language for object-oriented programming. Largely because the things they 'missed' at first turned out not to be so important after all.

That said, what I miss most is the ability to override operators, not just methods. The syntax really is clumsier when you have to define/override methods instead of operators.

Consider, for example complex number arithmetic. It is really elegant in C++. Not so in Java. But this turns out to have minimal impact on most real projects.

Some people complain about the inability to do multiple-inheritance. But the most useful kind of multiple inheritance IS the kind that Java does with the 'interface', so you shouldn't really miss it that much.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.