Life is great and everything will be ok, Kotlin is here”- claimed Christina Lee and Jake Wharton during their talk on Google I/O 2017 conference. Kotlin programming language seemed to be one of the widest discussed topics during and after the conference. Mobile technologies market is very dynamic, and it seems that introduction of the new officially supported by Google language will change a lot the way we develop Android apps in next years.

kotlin programming language


Despite being created only 6 years ago, Kotlin has already made some commotion. Statically-typed, object-oriented, yet using all the sugar of functional programming, it seems to be a very promising alternative for Java 7- based Android platform. As this new programming language from JetBrains is gaining more and more popularity, after Google I/O 2017 we can be sure that Kotlin is here to stay and (as some say) maybe even replace Java in Android development.

Let’s go through some examples of Kotlin features and compare it to Java and other popular languages. Firstly, it has to be mentioned that Android Studio 3.0 has got Kotlin support bundled, and if you want to use Kotlin in AS 2.0 or above you just need to install Kotlin Plugin.

Great thing is that you can use Java and Kotlin classes together (as Kotlin code is compiled to Java bytecode), so transferring your project from one to another or simply taking advantage of using both languages could not be simpler. Plugin also enables you to automatically convert Java files to Kotlin files.

The first visible difference we can see when creating a new class. Similarly to Scala, we can save many lines of code by creating a primary constructor with public properties- all the needed getters and setters are generated for us, with no single line of code.

Hero class in Java:

The corresponding code in Kotlin:

The more I dug into Kotlin, the more time-saving features I saw, and the more I thought it looked very similar to Swift. If you need to customize getters/setters, there is a mechanism that you may know from Swift as stored/computed properties (properties with/without backing fields). What is more, in Kotlin code we can access all these properties directly without the need to call get/set, and suitable methods are called underneath.

The next feature that Kotlin and Swift have in common is Null Safety. Kotlin introduces separate types for values that may contain null, to make developers aware of problems related to null pointer references. In Android Studio there already is a tool to help with that awareness- @Nullable and @NotNull annotations- but these cause only warnings, and in Kotlin if you want to assign null to not-null variable, you immediately get an error. Basically, there are only a few ways to get NullPointerException in Kotlin, and most of them are to explicitly unwrap null variable (ie. hero.weapon!!.attack()) or when calling Kotlin from Java code. So many hours typically wasted on debugging saved.

In Hero classes presented above Java would let us call

but in Kotlin

would produce a compile-time error. To make it nullable we should declare var weapon: Weapon? . A great way of handling nullable variables is Elvis Operator: after ?:  we put alternative value if the variable is null:

Kotlin contains some more features that Java used in the Android platform does not support (without use of external libraries) as lambda expressions, extension functions, operator overloading, type inference, smart casts, string templates (string interpolation), or trailing closures- all of them make it more similar to Swift than Java from the visual side. Describing all of them is a material for a separate long article, and if you are interested I encourage you to check out the docs ( My main point is to give you a brief overview on how many interesting things Kotlin has to offer.

kotlin android


There are also some great things dedicated to android development. One of them is Kotlin Android Extensions plugin. If you ever were tired of using findViewById  for binding each view in your Activity , and praised God/Jake Wharton for ButterKnife, you will love this tool. By adding

to your build.gradle  file you get a property-like access to all your views without the need of binding them yourself. No more boilerplate code!


The amount of Kotlin enthusiasts increases every day. Programmers appreciate its functionality, simplicity, and great support. Moreover, as Kotlin and Swift are very similar syntactically, it is easier for programmers and support teams to cooperate, and in general to develop apps for both platforms as bunch of code can be reused.

Currently Java is (and probably will be, at least for a couple of years) the most popular language for Android development, but it is not unlikely that Kotlin will gain so much popularity, that in a few years a greater part of Android applications will be written in this neat language. As for now, my first few dates with Kotlin went really well, and I see some chances for a longer relationship.