Why we need Kotlin?

Foram Adeshara
3 min readJul 16, 2017

--

Why we need another programming language when we have such a productive language called as Java for Andorid Development, which has been used since decades?. Is Kotlin that potent and useful? Will it stand equal or far better than Java? Well answer for all this depend on the furture reading.

Kotlin’s primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia. Its is a statically-typed programming language that runs on the Java Virtual Machine. It’s a new programming language targeting the Java platform. Kotlin works with all existing Java libraries and frameworks and runs with the same level of performance as Java. It is also used for server-side development (typically, backends of web applications), Android apps, and much more.

Kotlin is already been used by many major companies(Netflix, Uber, Trello, Pinterest, Corda etc). It has been used is numerous successful Android applications which are used by millons of people on daily basis (Pinterest, Basecamp, Keepsafe’s App Lock app). Using Kotlin in such a popular apps have enlighten us with the fact that is has shown huge decrease in code line and method count and great improvement in quality as well as speed of the app.

At recent Google I/O held on 17 May, 2017, Android team announced Kotlin as an official language for Android apps development (Link to offical blog of JetBrains). Kotlin doesn’t come from an academic or research background. It was built with the enterprise in mind. It has fixed all the major issues that Java had and catered us with new exiting features.

Consise: Kotlin code is said to be more concise than Java. It cuts down nearly 40% of code.

Eg: Java Code:

public static void main(String args[]) {

int a = 12;
switch(a){case 11:
System.out.println("a is 11");
break;
case 12:
System.out.println("a is 12");
break;
case 13:
System.out.println("a is 13");
break;
case 14:
System.out.println("a is 14");
break;
default:
System.out.println("a is not found");
}

Kotlin Code

fun main(args: Array<String>) {

val a = 12
val result = when (a) {
"11" -> print("a is 11")
"12" -> print("a is 12")
"13" -> print("a is 13")
"14" -> print("a is 14")
else -> "a is not found"
}

println("result = $result")
}

Safe: I have been working in Java platform since a long time and the most irritating exception would be Null Pointer Exception. Kotlin has guarded its code from NPE. Kotlin can have two types of variable: regular variable and non null variable(which is marked using “?”). If we declare regular variable null it would give Compile Time Error.

Interoperable: Kotlin is 100% interoperable with Java. Existing code in Java can be called from Kotlin.

Tool Friendly: Kotlin is developed by JetBrains, a company renowned for creating development tools for professionals. No wonder, it is tool-friendly. You can choose any Java IDE or build it from the command line.

Open Source: Kotlin is open source and it is distributed under Apache License, Version 2.0.

Well after seeing all the facts and figures Kotlin seems to be a great news for Android developers. A journey which started six years ago show signs of having pretty amazing results.

--

--