Kotlin for Android Developers

by Ryan Adhitya, Analyst Programmer at Mitrais

Recently, Google announced Kotlin as a first class language for writing Android apps. Kotlin is the new programming language developed by JetBrains, the company behind Android Studio. It is growing fast with over 10 million Lines of Code (LOC) in 8132 repositories on Github over the last five years. Kotlin has been adopted by many leading organisations, including Pinterest, Coursera, Netflix, Uber, Square, Trello, Basecamps, and Corda.

History of Kotlin

There are several reason why JetBrains developed Kotlin:

1. Increase their productivity.

All of JetBrains’s IntelliJ IDEA is written almost entirely in Java. They wanted to become more productive by switching to a more expressive language, but they could not compromise in terms of Java Interoperability or compilation speed.

2. Increase their sales of IntelliJ IDEA.

JetBrains needed to develop a language that did not replace the entire codebase and libraries that have already been built by JVM. We can still use Spring and Hibernate, or other similar frameworks in a project that is built using Kotlin. Kotlin itself will be open source, but they will provide an enterprise version of the IDE.

3. The new programming language is a hot topic back then.

JetBrains believed that having the trust from the community to build this new language project will not only drive the company’s business, but also attract more people

Kotlin for Server Side Development

Some of the features that make Kotlin powerful for server side development are:

1. Expressiveness

In Kotlin, you can implement much more logic with fewer characters which makes the Java look like boilerplate language. Kotlin also supports lambda expressions.

2. Scalability

By supporting co-routines, Kotlin delivers server-side applications with very small footprints that are scaleable to support large numbers of clients.

3. Interoperability

Kotlin is fully compatible with modern Java Frameworks.

4. Migration

Migrating large Java codebases to Kotlin will not be a problem since it supports gradual, step by step migration.

5. Tooling

Framework-specific tooling is readily available for common tools such as Spring, by using the Intellij IDEA plug-in.

6. Learning Curve

Learning Kotlin is very easy for Java Developers. We can use the automated Java to Kotlin converter which is included in the Kotlin plugin to help us.

Kotlin for Android Development

Kotlin is also great for Android development, as Google has made Kotlin a first class programming language to build Android applications. Some of the reasons are:

1. Compatibility

A Kotlin app can run on older Android device since it is fully compatible with JDK 6.

2. Performance

Kotlin runs just as fast as Java. Using lambdas it even runs faster than Java.

3. Interoperability

By providing full interoperability with Java, Kotlin supports all Android libraries and even runs faster than Java written code.

4. Footprint

The Kotlin runtime library is tiny. The actual app only adds 100KB to the size of the apk file.

5. Compilation time

Kotlin supports efficient incremental compilation which is as fast or even faster than Java.

6. Learning curve

The automated Java to Kotlin converter makes learning Kotlin very easy for Java developers.

Final Thoughts

Kotlin cuts down the boilerplate a lot when developing an application, such as delegating one of the most frequent basic tasks of programming (null checking) to the compiler. In my opinion, that advantage alone is enough to switch from Java to Kotlin.

The future for Kotlin looks very bright, thanks to Google’s announcement of Kotlin as its first class language. There is a lot of trust in Google in the programming community, so if Google says it’s good enough, people tend to believe it’s actually good enough. The adoption of Kotlin also has multiplied four-fold since last year.

It should be noted that Kotlin is not perfect and is not a replacement for Java. However, if there are instances where Kotlin is slow to handle or could not handle, we can always use Java since the two languages can exist side by side in a project.


Get the latest news from us to your inbox

(Weekly newsletter)

Leave a comment

from Indonesia:
from Australia:
from New Zealand:
from Singapore:
Our social media
© Copyright 1991 - 2022 Mitrais