Friday 2 March 2018

Started with Kotlin on Android.

why you should start using Kotlin for Android:

Here are five reasons why Google made Kotlin an official Android coding language and why you should use it for your next Android project:
1. Easy to Set Up:
Previously, developers had to use a plugin to add Kotlin into their Android projects. But with Android Studio 3.0, using Kotlin for Android development has become a whole lot easier. You simply need to tick the ‘Include Kotlin Support’ box while configuring your new project in Android Studio. 

2. Inter-operable With Java:
Kotlin is a Java-based programming language and inter-operable. You can seamlessly call Java code using Kotlin and vice-versa. This makes it easier for you to use Kotlin in your existing project with your old Java code. Both the languages generate similar byte-code. So, you can write simple parts of your app using Kotlin to get familiar with its constructs and syntax. The rest of your code can still be in Java. The Kotlin-Java mix can work very well for your Android project and you can opt for converting your entire Java code-base into Kotlin, eventually.

3. Minimizes Boiler Plate Code:
‘Boiler Plate’ in the programming context means the lines of code that you add to your apps code-base but doesn’t actually add to the function of your code. Kotlin uses various handy tricks and methods to help you significantly reduce the extra lines of codes and create relatively smaller file sizes. The fewer lines of code further enhance the speed of your app development life-cycle. 

4. Includes Synthetic Extension:
There are a plethora of extensions out there which simplifies the process of Android development using Kotlin. One such extension is called ‘Synthetic’. It is an extension that lets you remove the cumbersome findViewByID method to make navigating the coding environment easier. Developers used this method previously to interact with views. Now you can access the views directly with just a single line of code. 

5. No More NullPointerExceptions (NPEs):
NullPointerExceptions (NPE) has been one of the most common causes of app crash. Fixing the nullpointerexceptions and protecting your code using null checks is quite a time-consuming and daunting task for developers. But with Kotlin, NPE is a thing of past as null safety comes baked into the language’s type system. This lets you catch the NPEs during the compile time instead of the app crash at runtime.

Lest Create First Project With Kotlin on Android Studio.

1. Start a new Android Studio Project.




2. On the first screen, check Include Kotlin support



3. Select target Devices


4. select Activity



Congratulations You have Successfully created Your first Project With Kotlin.



No comments:

Post a Comment