We have a new member in our programming languages family and it’s none other than Kotlin. In Google I/O ‘17, they have finally announced that for android the official first class support will be given to the Kotlin. We can almost say that Kotlin is officially in for android development and java is almost getting pushed out of the frame. While java is generally preferred by almost all the app developers around the world, there are many reasons why java might not be the best programming language for Android Studio.
- It isn’t always favorable to call java a well-documented language. It has a number of endless try-catch blocks, less extendibility, null- unsafety (the infamous NullPointerException), and also a lack of functional programming features. Although Java is starting to add some functional programming elements but at its core Java is still a procedural language.
- Java’s syntax is too clumsy, specifically when we compare it with other modern programming languages. For instance, we know that even for making a simple ‘Hello World’ application we have to write extra code that includes declaration of classes, declaring other functions like onClickListener() and many more. That much amount of code should run behind the curtain, not in front of the programmer. That’s something which should be handled by backend software like compiler or interpreter.
- Lack of lambda functions is also one of the main reasons for the termination of java from android studio. Eventually with the time we have seen that lambda functions are the most beautiful advantages that any other programming languages can have. All the other modern languages like Python and Swift are having great support of lambda functions while if we talk about java, its designers are still trying to add them in it.
Advantages of Kotlin
There are many programming languages that you might have considered, that are designed to run on the Java Virtual Machine. Although there are many languages that can compile java bytecode, but there are few specialties of Kotlin that make it way better than the others.
- Interchangeability with Java: It means that while working on a new Kotlin projects you can use the Java libraries and frameworks. This is made possible by using advanced frameworks without any need to change the whole project in Java. The side by side existence of both Kotlin and Java classes in the same project is possible. We can equip Kotlin code in some other android studio project without making a whole new project specifically for Kotlin.
- It is an excellent open source development platform that helps the developers to make their application development faster. Due to its easy and short syntax, it requires 20% less coding as compared to Java.
- Kotlin’s one of the important features is that it aims at eliminating the null references from the code, also denoted as ‘The Billion Dollar Mistake’. Java has this pitfall of accessing a member of a null reference, resulting in a null reference exception. In Java it is called NullPointerException. Kotlin’s type system distinguishes between references that can hold null and those that cannot hold null value.
- Excellent Android Studio Support: Kotlin is developed by JetBrains and it is the company behind IntelliJ- the IDE that Android Studio is based on. It is quite amazing to see the excellent support that Android Studio has for Kotlin. All you need to do is install the Kotlin plugin, and Android Studio will make Kotlin configurations in your project as straightforward as opening a few menus.
With Android studio version 3, Kotlin will be shipped and will be ready to use for the developers. This is the most perfect time for every android lover if they want to start learning android app development because although Kotlin is a new language but for android development it is absolutely fresh and new.