In May At Google I/O 2017, Google announced that it would start supporting a new language for Android Developers. That language was Kotlin. Kotlin, the new general purpose programming language has been developed by Jetbrains. Yes, Jetbrains is the company behind the most popular Java IDE – IntelliJ IDEA. Kotlin compiles to the Java Virtual Machine (JVM) bytecode. It can therefore be used side-by-side with Java.
- Kotlin is Open-Source
At Jetbrains, the developers were tired of Java’s verbosity-they wanted a more concise language which was compatible with Java. When they started working on Kotlin, instead of keeping it as an internal project, they opted to open-source it. As of now Kotlin doesn’t profit from developers who use the language but it expects to make money from its Kotlin supporting core products. Kotlin has benefitted immensely from the feedback from big Java community and from being open sourced.
- With Kotlin You Write Less Code
In Java you have to write everything in details. Kotlin compiler on the other hand can understand from the code and write a lot of code itself. By one estimate you write at least 20% less code in Kotlin. It drastically reduces the boilerplate code. It is good with type inference. For example: Kotlin can infer types in variable declarations on its own. It all saves a lot of time and developers are definitely not complaining. Their productivity increases. They are able to spend their time more on the interesting part of the codes leaving Kotlin to manage the routine things on its capability.
- Google’s Support Gave Life To Kotlin
Google in its I/O annual summit 2017 declared Kotlin to be officially supported language for Android. Google gave Kotlin a new life.
Although before Google’s official announcement it was possible to build Android Apps with Kotlin there was a risk. If Google made changes to Android, apps written in unsupported Kotlin language could experience lot of bugs and there was a big chance the apps would not work the way developers intended. It would have been futile to work on Kotlin if Google announced support for its language Go or for Apple’s Swift. With Google’s announcement all of the fears were laid to rest and developers are now not afraid to develop apps on Kotlin.
- 100% Interoperability With Java
Kotlin and Java are two very similar languages. Kotlin has 100% interoperability with Java. You can have the codes from both Java and Kotlin in the same project and they will compile perfectly. Post compilation it would be difficult for you to tell the parts developed in Kotlin and the parts developed in Java separately. If you have been working on a Java project you can start working with Kotlin without starting afresh. When you work with Kotlin you get the benefit of vast Java commands, Java libraries and Java frameworks which you can easily use in your Kotlin project.
- Easy Learning Curve
Kotlin is easy to learn. It is a friendly language and can be learnt in a few hours by reading the language reference particularly if you know Java. Equipped with a lean and intuitive syntax it is designed for Java developers. It has a gentle learning path for them. When Java programmers start using Kotlin they find most of the Kotlin syntax very familiar.
- Kotlin- An Object Oriented As Well As A Functional Language
Kotlin has this edge over other languages. Its language has both object – oriented and functional constructs. It can thus be used in both Object Oriented and Functional Programming styles. You can also mix different elements from the two styles. If you are exploring functional programming, Kotlin has great features like higher-order functions, function types and lambdas.
- Kotlin Can Be Used For Server Side Development
Kotlin can definitely be used for server side development. It is 100% compatible with the JVM. You can develop server side development with Kotlin while maintaining full compatibility with existing Java based technology stacks. There are several frameworks like Spring, Vert.x, Ktor, Kotlinx.html etc. which can be used.
- Null Safety In Kotlin
Null safety in Kotlin is great. The development of Kotlin is aimed at eliminating the danger of null references from code. You can easily get rid of NullPointerExceptions. The Kotlin system refuses to compile code that tries to assign or return null. The Kotlin type system can distinguish between nullable references and non-null references.
- All Existing Java Frameworks And Libraries Can Be Used By Kotlin
All existing Java Frameworks and Libraries can be readily used by Kotlin programs. Kotlin programs can use all the advanced frameworks too which rely on annotation processing. Kotlin is a language that can be integrated easily. You can integrate it with Gradle, Maven and other build systems easily.
- Extension Functions
You can compose functions in Kotlin with extensions and operators. As in C# and Gosu, Kotlin gives you the ability to extend a class with new functionality without inheriting the class or without using any type of design pattern like Decorator. Extension functions are the functions that help us extend the functionalities of classes without touching the code.
- So In What Ways Can You Use Kotlin?
- Kotlin Setup
Kotlin is supported both by Android Studio and IntelliJ. You need to install Kotlin plug in. Actually Kotlin plugin is bundled with Android Studio starting from version 3.0.
Kotlin is available for free. You don’t have to pay anything when you develop a project on it. New android developers should definitely take up the language and experiment with it.
With Kotlin, programmers can now write safer and more stable and reliable codes. Companies like Pinterest, Square and Basecamp have been using Kotlin. More and more companies are now slowly moving towards Kotlin development. Its currently released version is 1.1.4-3 which was published on August 30, 2017. You can attend the Kotlin conference in San Francisco on 2- 3 November 2017. There are several Kotlin user groups too you can be part of if you are interested. If at any point you need help with Kotlin or Android App Development, call us. We can help you in sorting out the issues.