Kotlin ‘s benefits

Kotlin was designed by JetBrains (the creator of WebStorm, Android Studio, etc) and became official development language of Android since 2017.
With Kotlin you can say goodbye to NullPointerException.
The major benefit in my opinion is that Kotlin has optionals.
In Kotlin the default variant cannot be null. In case a developer want a nullable variant, the variant should be declared with “?” sign (like iOS in swift) => In this case Kotlin compiler force developers to check for Null Pointer Exceptions before using nullable variant.

Second Major benefit is Kotlin ‘s Android Extensions
Kotlin has great Interoperable with Java & Gradle & adds just a little to .apk file size.
In Kotlin there are no checked exceptions & less lines of code, and classes are public by default.
Start using Kotlin is very easy. If you want to convert a Java file to Kotlin you need to mark one java file => than press command Shift Option T -> your Java file will get translated to Kotlin and your project will get configured with Kotlin. (the translate isn’t flawless but works pretty good)

in Java null does not refer to any object – it’s kind of emptiness.
in Kotlin : null is a value – it’s kind of object.

kotlin benefits android
Google announced that it will officially support Kotlin on Android as a “first-class” language.

Show case

var: variant – can change.
val: is constant like java final.

Question mark  ?  ==> nullable
Elvis sign ?:  ==> shorthand for if (a != null) a else b
Exclamation mark  !  ==> not nullable

Optionals 1

Optionals 2

Optionals 3

Kotlin Android Extensions how to use

In app build.gradle file: apply plugin: ‘kotlin-android-extensions’ just below the ‘kotlin-android’ plugin
In MainActivity add this import import kotlinx.android.synthetic.main.activity_main.*
now you have in the class members of your xml TextView – Their name is just like their xml id
The code should looks like

Another article - but already about cross-platform development on Flutter

One thought on “Kotlin ‘s benefits”

  1. http://www.msapps.mobi

Leave a Reply