< Back to articles

Kotlin: the “Swift” for Android?

Why not Java?

The programming world is constantly developing, and so are the programming languages. They tend to become outdated and often aren’t able to compete with modern languages that better suit the needs of the industry. Java has been working hard to keep-up with the introduction of multiple modern features in Java 8, but unfortunately it seems that Android developers won’t be able to use them in the near future (natively).

Are there alternatives?

There are languages that allow you to make the code more readable and safe, drastically reduce the use of boilerplate, and even do wonders that Java can not. If you follow the trends in Android development, you’ve probably heard of Kotlin, Scala, Groovy, and other modern languages used to build apps. There were even rumors about Google’s interest in Swift (though only rumors). Either way, after Apple presented Swift as the official platform language, it seems only a matter of time until Google will do something similar.

The most probable successor?

One year ago it seemed that no languages met the requirements for the new official Android language. Some of them were raw, some were overcomplicated, some didn’t allow use of Java runtime or to switch from Java easily, and some had poor interoperability. Kotlin, of which I’m going to speak, was raw and buggy too. The progress it has made in the last year, however, is quite admirable. If any language was to be named the successor of Java for Android (or the official platform language alongside Java), I would say that Kotlin is the most probable candidate.

Kotlin advantages

  • Kotlin is developed by JetBrains, the team behind IntelliJ. It has some implications: Firstly, the support of Kotlin in the Android Studio (which is based on IntelliJ) is great and constantly improving. Secondly, it’s more of an industry language than an academic one, so it satisfies particular developers’ needs more precisely. Lastly, Kotlin is opensource and supported by its creators, and the community around it grows.
  • Kotlin is fully interoperable with Java. This means that not only can Kotlin classes work with Java classes and use Java libraries (the developer may easily integrate Kotlin in the existing Java project), there also exists a plugin that can fully convert Java code into Kotlin. Of course, sometimes this translation isn’t totally precise, but the results are very good.
  • Kotlin has a very small learning curve for Java developers (compared to Scala for example), and is easily readable. I was able to do a code review even without a deep knowledge of the language.
  • Compared to other Java libraries, Kotlin is quite lightweight (it has 7000 methods “only”).
  • All those sweet features that Kotlin supports: lambdas, null safety, extensions, data classes, optional arguments, etc. Antonio Leiva has a series of articles about Kotlin and even a book where these features are described in detail. In addition, Kotlin is a productive language: it doesn’t have a lot of features that complicate the learning process or make the language clumsy.

Here is a good comparison between Kotlin and JVM alternatives. You can see there that Kotlin is relatively lightweight, fast, and the most concise.

Why isn’t Kotlin so popular then?

Well, firstly, Kotlin isn’t very mature yet. The first release (v1.0) was only this year in February, and the language is constantly developing. Secondly, Swift is so popular because Apple supported it as the official language. As for Kotlin, it’s regarded as just some third party product for now. According to some rumors, Google doesn’t consider it as the official language for Android due to some drawbacks (the build times mainly). The general reception in the community is very good, however. There are many pro-Kotlin blog posts and articles among well-known Android developers and very little against it. For example, here’s the only one I found dated back to March. Already in May, after the release of v1.0.2, the author updated his opinion as positive, even though some drawbacks still exist. I personally think that Kotlin just needs time, and if the direction in which the team behind it is moving won’t change, Kotlin has all the chances to become very popular.

Is it the “Swift” of Android?

We can’t say for sure… It has so many similar traits. It is modern, industrial-strength, object-oriented language with functional power. It is compatible with the previous platform’s language (as Java with Swift is compatible with Objective-C) and works very well with the most popular IDE and build system. It is praised by the community and supported by its creators. Even the syntax of Kotlin and Swift are somehow similar (which is an advantage too, because iOS developers can easily understand Android code and vice versa, making it almost painless for leading developers to control multiplatform projects). But Kotlin won’t get the Swift fame until Google will acknowledge it. Is it a possibility in the near future? I think so. The progress it made in the last year is really impressive, and our team has started to write two new projects fully in Kotlin. We are excited so far, but there’s always room for improvement. We are looking to share our experience with the community, but as for Kotlin, only time will tell.

Georgiy Shur
Georgiy Shur
Android DeveloperBefore Georgiy used to live off Android, he used to live off poker. His interest lies in Kotlin, UX and preparation of delicious meals.

Are you interested in working together? Let’s discuss it in person!

Get in touch >