Introduction To Kotlin Programming & Features

Kotlin is a new language by JetBrains that targets JVM, JavaScript and Native platforms as well. In simple words, you can write code in Kotlin and that same code can be used across different environments. 



Kotlin is gaining popularity because it can be used as a first class programming language for developing Android applications. Both Java code and Kotlin code can co-exist in the same project. In this small series of Kotlin tutorials, we will write code that targets JVM. By targeting JVM means - output of the compiler is bytecode and this bytecode can run on JVM. Infact, you can call methods of classes written in Java from Kotlin and vice-versa. So if you are a Java or a C# programmer, picking up Kotlin is fairly easy. Most of the concepts are similar. Let's look at some of the features of Kotlin Programming language -

Kotlin is a statically typed language

 - Type checking is done at compile time. This is similar to Java where you cannot assign a string to an integer variable. But if you take an example of JavaScript it is not a statically typed language because type checking is not done at all.

Kotlin is an Object Oriented Language

 - It is a standard object oriented language that has classes and objects. It has all the features that you have in Java - Encapsulation, Inheritance, Polymorphism and Abstraction which helps to write maintainable and scalable code.

Kotlin is also a Functional Language

 - Being a functional language, functions are treated as a value just like an integer or a string. You can store functions in a variable, pass them as a parameters and even return functions from functions. It is a language with first class functions and higher order functions.

 - If you do not have a background of how Functional Programming works - you will learn as you progress. But functional programming helps to achieve functionality with fewer lines of code and code that is easily testable.

 - Kotlin supports Lambda expressions and extension functions. You can add functionality to existing classes using extension functions.

Kotlin is Safe

 - It prevents most of the errors at compile time. It is strict and helps avoid errors at runtime. Most of us are familiar with NullPointerException. Kotlin handles this reliably at compile time. It has an excellent support of Nullable Types.

Kotlin is open source

 - All the code is available at Github. You can check out the source code of the language, compiler and other libraries and tool. You can use the source code freely.

These are some of the features of Kotlin. You will learn about other features such as Type Inferencing, String Templating, Destructuring Declarations etc as you progress through these articles. There are various ways by which you can start working on Kotlin in no time.

  • You can write, compile and run the program online. Just visit the link Kotlin
  • You can install plugins in your existing IDEs like Eclipse and IntelliJ
  • Or, download the latest version of Intelli J Idea with full Kotlin Support.

We will setup and install required tools to create Kotlin program in our next article. Let us know if you have any concerns or issues.Till then Happy Reading.

 >> WANT SUMMARY OF THIS ARTICLE? WATCH THIS SMALL VIDEO << 




Comments

Popular posts from this blog

Create Android Apps - Getting Started

Polymorphism in Kotlin With Example