Kotlin: the “Swift” for Android?

Georgiy Shur
Ackee
Published in
4 min readNov 11, 2016

Why not Java?

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

Are there alternatives?

There are languages that allow 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 some rumors about Google interest in Swift (though only rumors). Either way, after Apple presented Swift as official platform language, it seems only a matter of time Google will do something like that.

The most probable successor?

One year ago it seemed that no languages meet the requirements for the new official Android language. Some of them were raw, some were overcomplicated, some don’t allow to use Java runtime or switch from Java easily, some have poor interoperability. Kotlin, of which I’m going to speak, was raw and buggy too. But the progress it did make in the last year is quite admirable. Now, if some language have to be named as Java successor for Android (or be 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 Android Studio (is based on IntelliJ) is great and is improving. Secondly, it’s rather an industry language than academic, 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. It means not only that Kotlin classes may work with Java classes and use Java libraries (the developer may easily integrate Kotlin in existing Java project), there exists a plugin that may 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 (comparing to Scala for example) and is easy readable. I was able to do code review even without the deep knowledge of the language.
  • Comparing 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. On the other side, Kotlin is a productive language: it doesn’t have a lot of features that complicate the learning and make the language clumsy.

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

Why isn’t Kotlin so popular then?

Well, firstly, Kotlin isn’t so mature yet. The first release (v1.0) was this year in february only, and the language is constantly developing. Secondly, the Swift is so popular because Apple supported it as the official language. As for Kotlin, it’s just some third party product for now. And according to some rumors, Google doesn’t consider it as the official language for Android due to some drawbacks (the build times mainly). But the general reception in community is very good. 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 march. And already in may, after the release of v1.0.2, the author updates 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 chances to become really popular.

Is it the “Swift” for Android?

We can’t say for sure… It has so much similar traits. It is modern, industrial-strength, object-oriented language with functional power. It is compatible with previous platform language (with Java as 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 may easily understand Android code and vice versa, and it will be almost painless for lead developers to control the multiplatform projects). But Kotlin won’t get the Swift fame until Google will acknowledge it. Is it possible in the near future? I think so. The progress it made the last year is really impressive. And in our team, we’re starting to write two new projects fully in Kotlin. We are excited so far, but there’s even room for improvement. We are looking to share our experience with the community, but as for Kotlin, only time will show.

--

--

Georgiy Shur
Ackee
Writer for

I work as a senior Android developer in Ackee. Trying to follow the new trends in my field and occasionally share my experience with others.