Kotlin is so cool and easy to learn

kotlin logo

I enjoy developing Android applications. When I’ve read couple of months ago Kotlin has been added as a official language to Android Studio I finally decided to learn it. Up to that point I had been hearing only good things about Kotlin.

I don’t know when I first heard of Kotlin but probably year and a half ago when I became interested in Android mobile development, again (“again” because I was having on and off relationship with Android because of my distaste for Java). It stayed in my mind because it’s developed by JetBrains, a company which develops software products that make programmers more productive at developing all sort of applications. I also own a licence for one of their products (WebStorm) and use couple of others that are shipped under free, so called community, edition.

Android Studio is official IDE from Google for developing Android applications which in fact is based on JetbBrains’ software.

Kotlin is a modern programming language that makes you write less code in Java. It’s not a new language but to me it looks like a language full of syntactical sugars for programming Java applications. It has good documentation which feels more like a guide and is easily comprehended.

There a quite a few things I like about it:

  • the way classes are instantiated with var/val without specifying new keyword (variable type if inferred from class used)
  • functional programming (have I already mentioned I like the paradigm??)
  • function extensions (I call this monkey-patching but without negative sound the term has in JavaScript world)

After reading few tutorials and official documentation, I decided to apply it by rewriting/refactoring existing app I’ve created a while ago to Kotlin. So that I have hard evidence how Kotlin simplifies code. I am comfortable with using a subset of Kotlin features at this stage. I also noticed Android Studio suggests to me from time to time a code simplification which happen to teach me something new about Kotlin.

The following deserves its own post but when I switched to Kotlin, at the same time I also incorporated Reactive Extensions into my development workflow (RxJava/RxAndroid). That’s because:

  • I way already familiar with Reactive Extensions from JavaScript,
  • it plays nicely with functional programming
  • it makes switching from main thread to another and back to main thread a lot easier (so app doesn’t freeze in event of long computations)
  • it makes dealing with new permission model introduced in Android 6 a breeze.