March 23, 2016

A team of JetBrains developers developed a language called Kotlin which runs on JVM and can be compiled to JavScript source code. The name Kotlin comes from the island near St. Petersburg. They released their stable version 1.0.0 on February 2016.

In 2011, JetBrains unveiled their project Kotlin. According to JetBrains lead “Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of Scala. However, he cited the slow compile time of Scala as an obvious deficiency.”

Kotlin is a pragmatic programming language for JVM and Android that combines OO and functional features and is focussed on interoperability, safety, clarity and tooling support.
Being a general-purpose language, Kotlin works everywhere where Java works: server-side applications, mobile applications (Android), desktop applications. It works with all major tools and services such as

1. IntelliJ IDEA, Android Studio and Eclipse
2. Maven, Gradle and Ant
3. Spring Boot (Kotlin support released today!)
4. GitHub, Slack and even Minecraft

As an Android Developer we are obliged to use Java 7, even the Java 8 is not meeting the requirement which should be present in the modern language. All thanks to the JVM, Android code could be written in any languages which generate Byte Code. Groovy, Scala, Clojure and Kotlin are few of the languages which can be used as an alternative to the lJava which generates ByteCode.
Here the question arises, why we should switch from Java to Kotlin. Few of the advantages of Kotlin over Java are as follows:

1. MORE EXPRESSIVE: Much work can be done in less line of Code.

For Example: In java, we will do this:

public class Contact {

    private int id;
    private String name;

    public String getName() {
        return name;

    public void setName(String name) { = name;

    public int getId() {
        return id;

    public void setId(int id) { = id;

    public String toString() {
        return "Contact{" +
                "id=" + id +
                ", name='" + name + '\'' +

On the other hand in Kotlin we can perform this operation in few lines, like below:

data class Contact(var id: int, var name: String)

data class, this will auto generate all the fields and property, and some useful properties too like toString.

2. SAFER: Every developers had faced a NullPointerException in his code, however, in Kotlin we can save a lot of time solving the NullPointerException. All we need to do is to specify the value as null. If that particular object can be null, and we can check its nullity before using it.

For Example: In Kotlin we can define the below things;

// Contact can be null
var contact: Contact? = null

The use of this symbol(‘?’) is called safe call operator.

3. FUNCTIONAL: Kotlin has a nice way dealing with Collections
4. EXTENSIVE FUNCTIONS: Developers can extend any class even if we don’t have the particular class’ source code.
5. INTEROPERABLE: One of the best features, Java and Kotlin can be used all-together in a project.

We will be exploring this language Step-by-Step, so stay tuned. Till then Happy Coding.