Should I learn Java or Android?

Programming language for developing Android apps

These programming languages ​​can / should be used for the development of Android apps.

There is currently a wide range of programming languages ​​that are intended both for creating Android apps and are supported by the manufacturer Google. The best known and most used language is definitely Java. The complete integration into the development environment of Google and the possibility to use the well-known IDE Eclipse, together with the simple syntax and the comprehensive framework, make Java so popular. But there are alternatives.

Java is the top dog

Similar to the Java Virtual Machine on desktop devices, the Dalvik Virtual Machine on Android devices converts Java code into bytecode, which is then interpreted by the respective processor. From version 5.0 Lollipop the DVM has been replaced by an Android runtime. In contrast to the just-in-time compilation of the virtual machine, compilation is now carried out directly on the instruction set of the respective processor. In addition to the lower processor load, the advantages are the faster start of apps, since the binary code is only generated once and not, as with a JIT compiler, every time it is called.

Kotlin is built into Android Studio

At its last developer conference I / O, Google presented the complete integration of Kotlin in Android Studio and its framework. Kotlin is compatible with Java, which means that Java code can be easily integrated and used in Kotlin projects. Despite its recent past, Kotlin is enjoying growing popularity. However, example code and references are far more sparse than is the case with Java. The official documentation will help you get an overview of the language and solve minor problems.

C and C ++ are possible with adjustments

C ++ is suitable for people who want to be much closer to the hardware and who want to do without ready-made functions from Google as far as possible. This language is also supported by Android Studio, but requires the integration of external components. The Android Native Development Kit together with the external build tool CMake and the debugger for native code, LLDB, make it possible to work with C or C ++.

C # over Xamarin

The Xamarin framework creates the prerequisites for using C # together with Visual Studio for app development. Due to the necessary integration of various Xamarin libraries, the programming feels very much like Java, as these simulate the interfaces of the Android framework. The structure of an app interface using XML files is identical, as is the necessary overwriting of activity methods and external classes.

Presentation of the languages ​​and their advantages and disadvantages

Java also shows its strengths in the Android environment. The combination of simple syntax and a comprehensive framework enables you to get started quickly. However, the Android framework does not yet support all of the new features added with Java 8. For event handlers of UI elements and the expansion of classes, relatively extensive boilerplate code is sometimes required.

With the new Kotlin language from the well-known IDE manufacturer JetBrains, this effort is significantly reduced in places. The syntax has also been simplified even further. Well-known code constructs such as switch statements are combined with lambda expressions, in general Kotlin uses many Java 8 innovations as standard. Annoying NullPointer exceptions from Java are now a thing of the past. Automatic assertions ensure that an object must not be null, while additional syntax constructs prevent methods of a null object from being called. All in all, many improvements that lead to more compact code.

In the days of the DVM (Dalvik Virtual Machine), C ++ was a real alternative to Java for the most efficient apps possible, since its programs are compiled into binary code. This is particularly advantageous for computationally intensive and time-critical applications; in some cases, comparable programs in Java were up to 100 times slower. With the introduction of the Android Runtime, this difference has been drastically reduced, in most cases nowadays both candidates are the same. The development effort in C ++ is still much more time-consuming and complex, since working with pointers and references is essential and many parts of the Android framework cannot be used. Its interfaces are only compatible with Java and Kotlin.

C # is similar to Java. Due to the non-official Xamarin framework, however, functions from the latest Android versions must first be recreated. This results in a time delay. Since mostly not only the latest but also older versions are developed, this does not play a major role. Anyone who is used to developing with Visual Studio and C # will find a quick start here.

application areas

The high-level languages ​​Java, Kotlin and C # mentioned above are suitable for effective Android development. For people who rely on the official framework and want to get updates as soon as possible, Java and Kotlin are recommended. C ++ is mostly only used in a specific part of an app over which the greatest possible control is important. Doing the entire development in C ++ would simply be too time-consuming and bring little to no advantages.

Recommendation to you

For an easy introduction, I recommend Kotlin, even if you already have experience in Java. Shorter and more understandable code, due to some syntax innovations, together with the interoperability with Java and the good integration in Android Studio make Kotlin my favorite language.