Why developers prefer Kotlin. The key Kotlin features & updates
Tags: kotlin, androiddev, programming
Published: 2018-10-25 11:25:25

---
layout: post
title: "Why developers prefer Kotlin. The key Kotlin features & updates"
published: true
description: How was Kotlin invented and why? What cool features does it offer? Why do developers so love it? Why do we use it for Android dev? Get to know the answers!
tags: kotlin, techtalks, androiddev, programming
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/uu5un0cciq612upjp8ut.png"
---


Kotlin is a statically-typed programming language, created by JetBrains company, located in Russia. Being fully compatible with Java, it runs on the Java Virtual Machine, has readable syntax, and can be compiled to JavaScript source code. 

According to <a href="https://insights.stackoverflow.com/survey/2018/">Stack Overflow Developer Survey 2018</a>, Kotlin became the second most loved language and the fourth most wanted among the developers worldwide. TechBeacon journalists included Kotlin in the list of <a href="https://techbeacon.com/5-emerging-programming-languages-bright-future">5 emerging languages with a bright future</a>.

Though Kotlin is pretty young, many famous companies have already written their applications in it. Pinterest, a popular image-sharing social service, had decided to move away from Java almost once Kotlin first version was released, and presented pros and cons of using it in 2016, even before Google announced its official support for Kotlin. 

Coursera, an educational company offering online courses of remarkable international universities, also chose Kotlin. Other examples of applying it in the creation of famous products are Uber, Trello, Basecamp 3, Shadowsocks, Evernote, Twidere for Twitter, etc.


<h3>The creation of Kotlin</h3>

Kotlin was invented to solve developer challenges of JetBrains. They needed a simpler tool than Java to work with their main product, called IntelliJ IDEA, totally written in it. The guys investigated the alternatives, stayed unsatisfied, and decided to invent their own language.

The goal was to receive an effective tool that could be used together with Java in custom Android app development and work everywhere where Java works.

The development of Kotlin started in 2010. Six years later, in February 2016, we saw the appearance of the first Kotlin version – 1.0. In 2017, at Google I/O annual conference, Kotlin was announced an <a href="https://www.theverge.com/2017/5/17/15654988/google-jet-brains-kotlin-programming-language-android-development-io-2017">official language for Android development</a>.


<h3>The key features of Kotlin</h3>

Kotlin offers <a href="https://blak-it.com/blog/why-use-kotlin-for-android-development/">a number of advantages of using/learning it</a>. There are also many things missed in Java and fulfilled in it: Lambda expressions + inline functions, smart casts, extension functions, companion objects, primary constructors, properties, and more.

At the same time, Kotlin programmers have access to all Java frameworks and libraries while having the ability to write more clear and concise code. They can use both languages when building a mobile solution and easily migrate their projects if needed. 

Artem Korolchuk, the head of BLAKIT Android development team, named the main Kotlin features: 

- <b>Null-safety</b> – getting rid of constant NullPointerException is a great thing about Kotlin.

- <b>Extension-functions</b> – a useful thing allowing programmers to add the functionality to already existing classes. It also enables to make the code more readable and logical, get rid of static Utils-classes, and write your own DSL.

- <b>Coroutines</b> – concurrent programming is getting more and more simple. It seems that Rx and the ability to simply switch between streams had come to us quite recently. But in Kotlin coroutines made it even much easier. Hope, with their help developers, will no longer neglect to perform relatively “heavy” tasks in the background stream, leaving the main one to perform the functions that were originally assigned to it, namely processing, update, and interaction with the UI.

- <b>There are many other useful things that involve</b> functional programming (especially concerning the work with collections), delegates, default and named arguments of functions, inline functions… The list is long.)


Noteworthy that Kotlin is rapidly developing and improving: updates, either large or minor are released quite often. For instance, some important updates were implemented in <b><a href="https://kotlinlang.org/docs/reference/whatsnew12.html">version 1.2</a></b>. Artem Korolchuk highlighted the main changes that were made:

- Array literals in annotation @CacheConfig(cacheNames = ["books", "default"])
- Checking whether a lateinit var is initialized this::lateinitVar.isInitialized
Information from explicit casts is used for type inference val button = findViewById(R.id.button) as Button
- Smart cast improvements
- A set of extension functions was added for manipulating lists fill, replaceAll and shuffle for MutableList, and shuffled for read-only List


Recently, a new version providing substantial updates - Kotlin 1.3 - has been released. You can see what was added and changed <a href="https://kotlinlang.org/docs/reference/whatsnew13.html">in this article</a>. 

Also, find out what are the <a href="https://blak-it.com/blog/why-use-kotlin-for-android-development/">Kotlin advantages and why did we move away from Java to Kotlin</a>.