Since long we have known and uses Java as the primary language for android app development. But recently a comparatively new language called Kotlin is taking over java in android development , A lot of developers now chooses Kotlin in their new android projects instead of Java.
- What is Kotlin
Kotlin is a general purpose, open source, statically typed programming language for modern multi-platform applications. Kotlin combines object-oriented and functional programming features. It is mainly focused on interoperability, safety, clarity, and tooling support.
Kotlin is developed by JetBrains,the company behind IntelliJ IDEA ,in 2010 and has been open source since 2012.
In July 2011, JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year. Development lead by Andrey Breslav stated that Kotlin is “better language” than Java, but still be fully interoperable with Java code, allowing companies to make a gradual migration from Java to Kotlin.One of the main goals was to compile as quickly as java
In February 2012 JetBrains open sourced the project under the Apache 2 licence.
Officially stable release Kotlin v1.0 was released on February 15 ,2016.
In 2017 annual developer conference held by google ( Google I/O ) announced first-class support for Kotlin on Android.
The name comes from Kotlin Island, near St. Petersburg Russia .
- Java or Kotlin for Android development
In case of android app development Java is most favourite language of many developers .But did you know that kotlin is ready to challenge Java’s leadership in the Android application development and a lot of developers are switching from java to kotlin.
Let’s have a detailed comparison of java and Kotlin.
In case of android development Java is mostly used and favourite of many developers also Android itself is written in Java. Java is a object oriented programming language that holds the cap of second most active programming language ion Github. And probably one of the oldest programing language around 20 years of active.
Pros of Java
- Simple : Java is easy to learn,use,write,compile and debug than alternative programming languages.
- Compilation speed is high
- In case of cross platform applications Java is a far better choice .
- Most of the android applications are running on Java and A lot of java libraries are available for android SDK
- Java has a large open-source ecosystem, partly as a result of Google’s adoption of the Java Virtual Machine (JVM) for Android;
- In comparison to Kotlin Java applications are more compact and lighter
- The build & compilation speed is high than Kotlin
- Lot of tutorials and online materials are available for android development using java ,In case of Kotlin as its a new language the materials are limited.
Cons of Java
- Java has limitations that cause problems with Android API design
- As compare with Kotlin , More code is needed to be written in java .
- It is slower and more memory consuming .than many other language
Pros of Kotlin
- Fully compatible and easy to convert from java to Kotlin : Just install Kotlin plugin in Android SDK and sync gradle then click Convert to convert java files to Kotlin
- All major java frameworks started supporting Kotlin (Like Spring started support Kotlin from Spring 5)
- Well management in NullPointerException : Introduction of !! operator aimed to eliminate NullPointerException’s the code.
- Fewer chance to get errors in code and in compare to java less coding needed.
- Easy to switch from Java to Kotlin
- All java libraries are fully compatible with Kotlin
- Compilation time in kotlin are improving well and almost same as that of Java.
Cons of Kotlin
- Slower compilation speed than Java
- Switching entire team from Java to Kotlin might be challenging
- The availability of developer community and finding answers for questions are limited , but its growing fastly.
- In android studio auto_completion are working slower than Java.
Kotlin version history
- Kotlin v1.0 : Official stable version of Kotlin released on February 15 ,2016.
- Kotlin v1.2.2 :Adds support for Gradle build cache
- Kotlin v1.2.6 : latest version available and released on Aug 1, 2018.
- Kotlin v1.2.3 : Adds a new declaration in the standard library, which imitates the suspend
- Kotlin v1.3 : upcoming version
In my opinion If you are a beginner in android development and you have a decent knowledge in Java , its better to start with Kotlin instead of Java. But of course you might have some good knowledge in Java.
Kotlin is now an Official language for android development and a lot of brands like Amazon,pintrest and netflix are already converted to kotlin. As the article name says it is a new era in android development and Kotlin is only beginning to ride in the growth curve. With support from Google and heavy-hitting brands making the switch kotlin quickly proving itself to be a superior programming language for android application development.
Some Useful tutorials