Why you should start using Kotlin for Android?

What is Kotlin?

Kotlin is a statically typed programming language for the JVM, Android and the browser which is now officially supported by Google For Android.

Kotlin language is developed by JetBrain who is creator of IntelliJ IDEA. Android Studio is also based on IntelliJ IDEA. In Google I/O 2017, Kotlin is declared as official language for Android development.

Why Kotlin?

short and sweet

Write less and perform more operations. In java, if you want to create a data class, it will take a long time to create members, getter & setters. But with Kotlin, you can do it with few lines of code like,

Kotlin will automatically generate necessary methods & toString() as well.

Null safe

When we write code in Java, developer requires to spend more time to fix NPE (Null Pointer Exception). But if you are using Kotlin, null exception will never happen as we need to explicitly initialize object as null. It will avoid null pointer exception for entire class.

Client expression on null pointer crash
Client expression on null pointer crash

Functional

You can use functional paradigm like Lamdas with Kotlin. It will be very easy to declare listeners & method calls by using Lamdas.

Flexible

You can use Java class & libraries along with Kotlin as interoperability is very much between both languages.

How to start using Kotlin in Android

From Android Studio 3.0, Kotlin is fully supported with it. For previous versions of Android Studio, you require to install plugin to work with Kotlin.

More to read.

Chapter 1 : Configuring Android Studio with Kotlin
Chapter 2 : Working with Variables in Kotlin (Android)
Chapter 3 : Working with Operators in Kotlin (Android)

Protected by Copyscape

Share on Facebook79Share on Google+16Tweet about this on TwitterShare on LinkedIn18Share on Reddit0Pin on Pinterest0Share on Tumblr0Email this to someone