Basic of Kotlin to get started in android Part-1

Kotlin is the new language based on JVM. It is taken the good parts of java. When I am talking about the good parts, it means to eliminate the boilerplate code and given better object orientated programming. As we know that Java is also Object oriented programming.  Kotlin is allowing the functional programming also. It is much compatible with Java and similar like Groovy.

Kotlin is developed by JetBrains team. I guess Everybody familiar with JetBrains, JetBrains has launched awesome IDE  Android studio and popular Java IDE IntelliJ. Android studio is using Gradle-based build tool which is implemented in Groovy language. So Kotlin is almost similar like Groovy which is created by JetBrains.

Now a day Kotlin attracting to most of the android developers to build the awesome android apps by using Kotlin programming, And every developer is loving because of its configuration from Java to Kotlin is pretty easy and simple.

Why Kotlin? Why does need to switch from Java to Kotlin?

Java is the largest used programming language in the world, which is officially used in Android application development. But it does not make sense that it is the best choice. Java is the very old programming language and it is not a modern and even version updates also coming very slow.

Recently java has launched the new version 8 which having added many new features including functional paradigm and procedural. Here you check Java 8 feature which I explained in one of my posts.

But from KitKat onwards, Android is used OpenJDK to build android apps, earlier was used Apache Harmony bridge. So there is a bridge gap between the Java JDK and OpenJDK. Android developers are not able to use many features of Java 8 and even to use  Java 8 feature now in Android N, we need to enable the Jack Compiler which supports target SDK version 24. Developers are stuck to use the feature of Java 7 and Java 6 which are even partially supported for android development.

So switching from Java to Kotlin is not only this reason, there are much more reasons which are encouraged to start using Kotlin. Java is still not handled the null pointer exception.  An Android application crash happened almost for this reason because the developer forgets to check the Null condition at some of the places. But if we check null pointer at multiple places it looks boilerplate code means many many places it required to use unnecessary duplicate code. Kotlin is handling this issue very smartly. You just need to declare at one place then it will handle every place.

What is the advantage of Kotlin?

There are many advantages of using Kotlin. Let’s see.

1.  Interoperable with Java: –  Now a day, An Android developer is very much comfortable to use Java programming to build the android applications. They will feel like obvious to switch in the different language. Kotlin is providing an option to the developers, they can convert whole java code in Kotlin for a single click. Wow, that’s pretty good :).

Not only to convert from Java to Kotlin is easy, As well as developers are used to Kotlin and Java programming together to compile and build. Ohh, sounds like crazy :).

Yes, Developers can use both languages in the same project. And if they want to convert all project in Kotlin then just one click is enough so far and it will be converted all code in Kotlin. In this case, learning and understanding of Kotlin as a programming become much simple and easy for every developer. Awesome 🙂

2.  Null Safety: – By using Kotlin no more null pointer exist. Kotlin is taken this type exception in top priority.

3. Great Tooling support: – Developers would not worry about what are the things are required to use Kotlin in Android studio IDE?  It is pretty simple and easy. Developers are required to tell to Tools component of Android Studio to “Configure Kotlin in a project”. Then tools will add all required plugins at required places. Android studio will not face any problem to compile and build Kotlin code. Sounds interesting 🙂

Wrapping- we have understood that there are a bunch of awesome features available in Kotlin which are the best parts of Java. But still not any programming language is all perfect. A developer will not get as much as the support as they expect because Kotlin community still less to help. Overall it’s a good time to start using all awesome features of Kotlin to build awesome android applications. Here is the official GitHub site to get a start.

In my Next tutorial, I will try to explore all features in deep. Here is my next tutorial of this series Basic of kotlin to get started in android part-2.

So please subscribe your email to get updated and if you like this post then share your feedback on below comment section.

Happy coding 🙂

Sunil Gupta

I am a very enthusiastic Android developer to build solid Android apps. I have a keen interest in developing for Android and have published apps to the Google Play Store. I always open to learning new technologies. For any help drop us a line anytime at

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.