Infogain Kotlin Android APP Development Consulting Web Framework Mobile on the Rise
Close Icon
×
Knowledge Center

The Rise of Kotlin: A statically-typed programming language

The Rise of Kotlin: A statically-typed programming language

Authored by:

UPAKUL BARKAKATY | Practice Lead, Mobility Solutions

JAGDEEP SINGH | Consultant

More than 10 years ago, in September 2008, the first commercial version of Android was released by Google. While the 'Core Android coding' is done using C and C++, Android Applications were written predominantly using Java. The Go Programming Language is also supported for a limited set of APIs. Programmers often contend with a variety of Java issues, including:

  • Null references that are controlled by the type system
  • No raw types
  • Arrays in the Java language are covariant
  • Java works with SAM-conversions
  • Use-site variance without wildcards

While Java is still used in many applications, the Kotlin programming language has been gaining in popularity among developers. Well known applications, such as Netflix, Twitter and Pinterest now use Kotlin. Let’s explore the background and features that are leading to the ‘rise of Kotlin.’

Introduction to Kotlin

Kotlin was introduced by JetBrains in July, 2011 for purpose of having the features that most of languages don’t have (Wikipedia). After a year of development, it was open sourced under the Apache 2 license. The language was named after an island, near St. Petersburg, Russia. Kotlin v1.0 was released on February 15, 2016 as a stable release, with the latest version v1.3, released in October 2018 containing many more features. With the release of Android Studio 3.0 in October, 2017 Kotlin is fully supported by Google for the use of Android Operating System. In addition, Google is in the midst of a lawsuit against Oracle for the commercial use of Java API, while the company is considering Kotlin as their official language.

“In 2018, among both innovative and mainstream IT adopters, Kotlin has an emerging market share that is growing rapidly, and we predict that it will have a competitive market share by 2020”. –

Gartner, IT Market Clock for Programming Languages, 2018, Mark Driver, Thomas Klinect, 24 April 2018

Why Kotlin?

Application developers have chosen Kotlin because the code is safer, leading to reduced errors and bugs. With Kotlin, the code base shrinks and increases in quality. Kotlin is equipped with many powerful features that speed up development including:

o Object declarations
o Parameter values
o Extension functions
o Null safety through nullable and non-nullable types, safe calls, and safe casts.
o Extension functions.
o Higher-order functions / lambda expressions.
o Data classes.
o Immutability.
o Type aliases

Migration from Java to Kotlin is easier with Kotlin. Since Kotlin is fully interoperable with Java code, this allows developers to gradually migrate from Java to Kotlin. Due to a reduced number of code lines, Kotlin saves time and the quality of code is increased. InfoWorld reports that Kotlin reduces the lines of code by 20-30%. Kotlin also supports REPL (Read-Eval-Print Loop) like Python, which actually helps developers to quickly run a part of code directly without actually running the whole application. REPL comes in the JetBrains IDE under the tools menu.

Key Features

Kotlin has an abundance of features which speed up the development time. Several features cover extension function, default and named arguments, inline functions, data class, companion object and more. Kotlin provides a clear and compact codebase that makes the code in production more stable and consistent. Bugs get detected at compile time, so developers can fix errors before runtime. In addition, Kotlin is not just limited to the Android platform. The language has proved that it’s a great fit for developing server-side applications, allowing a programmer to write concise and expressive code while maintaining full compatibility with existing Java-based technology stacks and a smooth learning curve.

“Null-safety” is one of the most popular key features of Kotlin. Nulls are the most error-prone points when working with Java. In Kotlin, nulls do not exist unless otherwise stated. No variable by default can be set to ‘null’ in Kotlin. If a developer wants a variable to accept ‘nulls,' they have to mark the type with a ‘?.’ From then on, the compiler will force the developer to check the ‘null’ before doing anything with the variable. Due to this, a ‘Null Pointer Exception’ does not occur in Kotlin. Other than this, it has ‘let’ and ‘Elvis operator’ which comes handy when the code inside the let expression is executed only when the property is not null. Thus let saves us from the ‘if else’ null checker too!

To date, only a small number of applications are using Kotlin on Google PlayStore yet most of the developers are shifting towards it. These applications include Twitter, Pinterest, Netflix and others as mentioned on the Developer site of Android. Many external libraries are also adopting the Kotlin language.

Kotlin can make an Android Developer’s life a lot easier. You can also get many Sample apps on the Codelabs developer site by Google with step by step development. In short, you should consider implementing Kotlin in your current or next Application.

Infogain Mobility Services and Solutions offers Enterprise Mobility Consulting and Enterprise Mobile Software Product & Application. To know more about Kotlin and its implementation please reach out here.