Comparing Android NDK and RenderScript

What’s NDK ?

The Native Development Kit (NDK) is a set of tools that allow you to leverage C and C++ code in your Android app. You can use it to build from your own source code, or to take advantage of existing prebuilt libraries.

The NDK is not appropriate for most novice Android programmers, and has little value for many types of Android apps. It’s often not worth the additional complexity it inevitably brings to the development process.

But it can be useful in cases in which you need to:

  • Squeeze extra performance out of a device for computationally intensive applications like games or physics simulations.
  • Reuse your C or C++ libraries.

What’s RenderScript ?

RenderScript is a framework for running computationally intensive tasks at high performance on Android.

RenderScript is primarily oriented for use with data-parallel computation, although serial computationally intensive workloads can benefit as well.

The RenderScript runtime will parallelize work across all processors available on a device — such as multi-core CPUs and GPUs — allowing you to focus on expressing algorithms rather than scheduling work or load balancing.

RenderScript is especially useful for applications performing image processing, computational photography, or computer vision.

To begin with RenderScript, there are two main concepts you should understand:

  • High-performance compute kernels are written in a C99-derived language.
  • A Java API is used for managing the lifetime of RenderScript resources and controlling kernel execution.

How NDK and RenderScript differ

Both NDK and RenderScript share the common goal of improving the performance of applications.

Each has its own advantages and drawbacks.

Advantages of NDK over RenderScript:

  • C++ code can be shared between Android and IOS, whereas RenderScript code can be used only in Android.
  • Easy integration with other C++ libraries.
  • No API limitations, while Android provides only few API for renderScript.
  • Debugging is easier.

Advantages of RenderScript over NDK :

  • RenderScript can use CPU, GPU, or other processing units, which leads to the huge performance benefit.
  • Android architecture independence across x86, mips, and intel, where as NDK code needs to be compiled for each different architecture.
  • Easier parallel execution.
  • Best for image processing, computational photography, 3D rendering, or computer vision.

Happy Coding :)

Also, Let’s become friends on Twitter, Linkedin, Github, and Facebook.