Kotlin – A new era in android development
From the bigining we know and use 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 development in their new android projects development instead of Java. Kotlin is a general purpose, open source, statically typed programming language for modern multi-platform applications. Kotlin development 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.
-
History
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.
Kotlin v1.2 was released on November 28, 2017. Sharing code between JVM and Javascript platforms feature was newly added to this release
The name comes from Kotlin Island, near St. Petersburg Russia .
-
Java Development or Kotlin Development for Android
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.
-
Java
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 languages
Kotlin
Kotlin was designed by programmers from JetBrains to add some modern features to Java that come in handy in mobile development. Kotlin is an open source, statically typed language based on Java Virtual Machine (JVM), but you can also compile it to JavaScript or Native for building code that can run on iOS. All it takes is installing the Kotlin Plugin and letting it configure your project.
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 : Added the possibility to reuse code between the JVM and JavaScript,new libraries introduced to help cross platform applications
- Kotlin v1.2.2 :Adds support for Gradle build cache Improves incremental compilation for Android and mixed Kotlin/Java projects. Provides IDE support for the new Kotlin style guide
- Kotlin v1.2.3 : Adds a new declaration in the standard library, which imitates the suspend modifier for lambda expressions. Adds support for TestNG in kotlin.test .Brings support for Android modules in multi platform projects.
- Kotlin v1.2.4 : Allows platform modules in experimental multi platform projects to have more than one expected By dependency; Enables support for cross in line suspend parameters in inline functions. Adds new inspections and intentions to the Kotlin IntelliJ plugin. Fixes a lot of known issues in the compiler and the IDE plugin and provides performance improvements.
- Kotlin v1.2.6 : latest version available and released on Aug 1, 2018. Adds optional expected annotations to multiplatform projects, Allows building multiplatform projects with IntelliJ IDE. Introduces experimental kapt mode aimed to speed up Gradle build. Adds new refactorings, inspections, and intentions to the IntelliJ IDEA plugin. Fixes a lot of known issues in the compiler and the IDE plugin and provides performance improvements
- Kotlin v1.3 : upcoming version
Conclusion
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.It is now the 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 development, quickly proving itself to be a superior programming language for android application development.
Also refer