Android: Java, C or C++?

The article you link to has good information. It also links to http://developer.android.com/sdk/ndk/overview.html which says:

The NDK will not benefit most applications. As a developer, you need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but always increases application complexity. In general, you should only use native code if it is essential to your application, not just because you prefer to program in C/C++.

Typical good candidates for the NDK are self-contained, CPU-intensive operations that don't allocate much memory, such as signal processing, physics simulation, and so on. Simply re-coding a method to run in C usually does not result in a large performance increase. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need. The NDK can, however, can be an effective way to reuse a large corpus of existing C/C++ code.


This is good question, AFAIK, c or c++ comes into picture when you really want to program something core dalvik feature than using Android API as specified you question, something like sensor related features or hardware.

If you want build app using API, it will be mostly in Java/XML.


Android is Linux underneath so you can run any language on it. I have run Perl scripts on an Android phone for fun. From a practical, application development point-of-view, Google's implementation of Java running on Dalvik would be the typical route to take.


Java always allows you to call "native code" components. However, you want to avoid them if possible because they can introduce subtle bugs and platform dependencies into your code.

I don't believe you can code a whole application for Android in C/C++ however -- you must have a Java wrapper at the very least.

Tags:

C++

C

Java

Android