On Android NDK website you can read:
The Android NDK is a companion tool to the Android SDK that lets you build performance-critical portions of your apps in native code.
...
If you write native code, your applications are still packaged into an .apk file and they still run inside of a virtual machine on the device
...
Using native code does not result in an automatic performance increase, but always increases application complexity.
How then can you gain on performance using C and NDK, if C is also compiled to VM code? You can bypass API, or C compiles to more optimal code, or what?
Or it is only "development speedup", so if you have some C code you dont have to port it to Java?
Edit:
I do not ask if "Java is slower than C". My consideration is, if C is compiled with gcc, then how the portability is solved (but this is a second question, in the background)
What are the portability implications of using the NDK?
The C code that the NDK allows you to add to your app is not compiled into VM code. It is compiled using gcc and links as a shared library that can be loaded and linked via JNI to Java. Therefore, you can gain performance by writing in C instead of relying on JVM optimization when writing Java code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With