Jump to content
Java or C++ for 3D programming on Android?
Asked by Philip Rideout
Posted Jun 06 2010 10:02 AM
I'm wondering what Android developers think of the Native Development Kit (NDK), which allows you to write C/C++ code instead of Java. Is the NDK only appropriate for porting an existing code base? Would it make sense to use it when writing a new Android-only game from scratch?
Personally I'm leaning towards using the NDK for any apps that leverage OpenGL ES, but I'm curious what others think. One reason I'm so interested in this topic is that I got some negative feedback regarding the fact that I used C++ instead of Objective-C in my iPhone 3D book.
Answered by zigurd
Posted Jun 30 2010 07:26 PM
Currently you have two choices: Write it in Java, or in C or C++ and use the NDK and JNIs. There are the beginnings of a third choice, called "RenderScript" buried in the source code for Froyo. Renderscript looks to be a kind of embedded, on-the-fly-compiled C subset.
But, with JIT compilation of Java code in Android 2.2, I wonder if RenderScript is an evolutionary dead end. So I would try coding your 3D in Java, and, if JIT-compiled Java does not result in satisfactory performance, or if pre-2.2 compatibility is a requirement, moving it to C and JNIs, using the NDK.