What is Kotlin?
Kotlin
is a programming language introduced by JetBrains, the official
designer of the most intelligent Java IDE, named Intellij IDEA. This is a
strongly statically typed language that runs on JVM.
This tutorial describes how to use Kotlin Android Extensions to improve support for Android development.
Why Kotlin?
100% interoperable with Java - Kotlin and Java can co-exist in one project. You can continue to use existing libraries in Java.
Concise - Drastically reduce the amount of boilerplate code you need to write.
Safe - Avoid entire classes of errors such as null pointer exceptions.
It's functional - Kotlin uses many concepts from functional programming, such as lambda expressions.
Why Kotlin?
100% interoperable with Java - Kotlin and Java can co-exist in one project. You can continue to use existing libraries in Java.
Concise - Drastically reduce the amount of boilerplate code you need to write.
Safe - Avoid entire classes of errors such as null pointer exceptions.
It's functional - Kotlin uses many concepts from functional programming, such as lambda expressions.
Following are some of the advantages of using Kotlin for your application development.
Easy Language − Kotlin is a functional language and very easy to learn. The syntax is pretty much similar to Java, hence it is very easy to remember. Kotlin is more expressive, which makes your code more readable and understandable.
Concise − Kotlin is based on JVM and it is a functional language.
Runtime and Performance − Better performance and small run-time.
Interoperability − Kotlin is mature enough to build an interoperable application in a less complex manner.
Brand New − Kotlin is a brand new language that gives developers a fresh start. It is not a replacement of Java, though it is developed over JVM. It is accepted as the first official language of android development. Kotlin can be defined as - Kotlin = JAVA + extra updated new features.
Following are some of the disadvantages of Kotlin.
Namespace declaration − Kotlin allows developers to declare the functions at the top level. However, whenever the same function is declared in many places of your application, then it is hard to understand which function is being called.
No Static Declaration − Kotlin does not have usual static handling modifier like Java, which can cause some problem to the conventional Java developer.
Kotlin compiler creates a byte code and that byte code can run on the JVM, which is exactly equal to the byte code generated by the Java .class file.
A simple program which written in to Android
public class MyActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity); } }
Below code for Kotlin same as above in to Android
Android Extensions is a part of the Kotlin plugin for IntelliJ IDEA and Android Studio. You do not need to install additional plugins.
All you need is to enable the Android Extensions Gradle plugin in your module's
build.gradle file:apply plugin: 'kotlin-android-extensions'
class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity) } }
