Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building fast Android app - Java or native? [closed]

Tags:

java

c++

c

android

I'm about to start building an Android app (I'm currently working on the web service and the database) and I'd like to know if there's a significant difference on the app speed between using Java or coding directly into C or C++.

The app doesn't contain any complex graphics or physics and its speed depends mostly on the transfer speed of several Objects to and from a REST web service.

Thanks in advance

like image 597
Santiago Martí Olbrich Avatar asked Mar 06 '13 22:03

Santiago Martí Olbrich


People also ask

Is C++ faster than Java on Android?

Though Java is a good language, C++ has quite a few more advantages for Android mobile development. C++ helps to include lower memory footprint as it has no garbage collection. C++ can compile all C programs virtually allowing the developer to reuse C software. On the other hand, Java programs run faster than C++.

Is Java still used for Android development?

Absolutely. Java is still 100% supported by Google for Android development. The majority of Android apps today have some mix of both Java and Kotlin code. Developers can build the same functionality with Java as they can with Kotlin.

Why does Android still use Java?

Android code is written once and to execute need to compile and optimise native code for better performance on various devices. Java has platform independent feature so it is used for android development. Java is very popular language due to its awesome features and performance.


1 Answers

Google says you probably should just stick with Java:

Before downloading the NDK, you should understand that the NDK will not benefit most apps. As a developer, you need to balance its benefits against its drawbacks. Notably, using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app—never because you simply 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. 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.

like image 88
Blorgbeard Avatar answered Oct 20 '22 02:10

Blorgbeard