On May 17, 2017, Google stood up in its yearly I/O conference and made a very interesting announcement: Android would now support Kotlin at a first-class level. This was huge news not only for Android developers, but for the team behind what was, and still is to this day, a very young programming language.
But where did Kotlin come from? Why was this seemingly small, unknown platform suddenly picked as one—of just two—officially supported languages for the biggest mobile operating system in the world?
The truth is, by the time Google made the announcement that day, Kotlin was already a buzzling platform with good prospects, and with which the tech community was familiar. Thanks to its Java roots, Kotlin could already be used for Android development, and it had some popularity among developers.
Kotlin was created by JetBrains, a software development company from Prague, Czech Republic. The company introduced Kotlin in July 2011, developed in a year by a team based in Saint Petersburg, Russia, who named the language after an island off the coast from the city.
In 2012, Kotlin went open source. Little by little, the programming language made its way into the scene thanks in part to JetBrains’ positive reputation, as the company had already introduced a number well-received tools and solutions for developers since its founding in 2000.
The platform runs on the Java virtual machine, which made it interoperable with Java code, a conscious decision by its creators, and one of the reasons why the language world eventually make its way into the Android ecosystem. Andrey Breslav, one of the original developers, said as much in a 2013 interview regarding Java compatibility:
“Every tool comes with a driving use case. We believe that for a new programming language, this use case is gradual migration, when the new language is being introduced little by little into a large code base written in the ‘old’ language. In our case, we pay a lot of attention to making mixed Kotlin/Java projects work smoothly.”
Breslav talked about IntelliJ IDEA, a professional Java IDE and one of JetBrains’ best known products. While they would not “rewrite the whole 10-year-old,” they would most likely start writing tests in Kotlin, “then new features, then maybe some existing subsystems that will be migrated to Kotlin while under refactoring.”
The result is that Kotlin can perfectly exist in the established Java ecosystem. That means being able to use existing assets and tools that would otherwise be unavailable (libraries, APIs and frameworks). “Some other new languages adopt a different approach and aim at abandoning the JDK and building their own better platform,” said Breslav.
Java compatibility was probably one of the main reasons why Kotlin was supported by Google in the first place. But beyond that, the language also seemed to improve o many of the issues developers had faced during the years.
Kotlin was conceived as an improved version of the programming language Scala, introduced in 2004, which itself was created to address many of the criticisms surrounding Java. By now, it’s clear the platform has had a positive impact in the ecosystem, and many point out the reasons why migrating to it is the right choice.
By the end of 2017, website The Register reported that Kotlin had already infiltrated more than 17% of Android apps developed with its IDE, Android Studio 3.0, which of course fully supports it. JetBrains, for its part, claims that apps written in Kotlin require about 40% less code than they would if written in Java.
Several high-profile apps for Android like Pinterest, Evernote, Trello and Square have used Kotlin in their code. The reason? Beyond bigger changes (though there’s a lot of familiarity here), most developers point out many small, quality-of-life improvements that can have a great impact. Things like type inference, smart casts, default arguments, null safety features, improvements on readability and much more.
Writing for InfoWorld, developer and editor Martin Heller was concise: “The short answer is that Kotlin code is safer and more concise than Java code, and that Kotlin and Java files can coexist in Android apps, so that Kotlin is not only useful for new apps, but also for expanding existing Java apps.” In short, he concludes there’s no real advantage to using Java above Kotlin, except maybe easier-to-find, more readily available documentation of the former for aspiring developers. But it might just a matter of time before Kotlin catches up.
While it’s clear that Android’s future is deeply related to Kotlin, it’s also evident that the programming language won’t limit itself to just exist in Google’s OS. Kotlin has lot of potentianl beyond Android, and as things stand, it’s a clear candidate for substituting Java as a whole.