Five years later, Google is still all-in on Kotlin

It’s been just over five years since Google announced at Google I/O 2017 that it would make Kotlin, the statically typed language for the Java Virtual Machine first developed by JetBrains, a first-class language for writing Android apps. Since then, Google took this a step further by making Kotlin its preferred language for writing Android apps in 2019 — and while plenty of developers still use Java, Kotlin is quickly becoming the default way to build apps for Google’s mobile operating system. Back in 2018, Google and JetBrains also teamed up to launch the Kotlin Foundation.

Earlier this week, I sat down with Google’s James Ward, the company’s product manager for Kotlin, to talk about the language’s role in the Android ecosystem and beyond, as well as the company’s future plans for it.

It’s no surprise that Google’s hope is that over time, all Android developers will switch over to Kotlin. “There is still quite a bit of Java still happening on Android,” Ward said. “We know that developers are generally more satisfied with Kotlin than with Java. We know that they’re more productive, the quality of applications is higher and so getting more of those people to move more of their code over has been a focus for us. The interoperability of Kotlin […] with Java has made it that people can kind of progressively move code bases over and it would be great to get to the point down the road, where just everything is all Kotlin.”

We’re not quite there yet, though, in part because the Java ecosystem is so big that it still has a lot of gravity. Because of Kotlin’s interoperability with Java, developers can mix and match libraries, but to get all of the benefits of Kotlin, developers have to stay within the Kotlin ecosystem. And despite all of the focus on Kotlin, it’s worth noting that the core of the Android platform and its APIs are still built on Java. There are now a handful of Android libraries that are written in Kotlin, but that’s obviously still only a small part of the overall platform.

But Kotlin today is also far more than just Android. Server-side Kotlin is becoming quite common at Google at this point, it seems, with over 8.5 million lines of Kotlin code in Google’s internal codebase to date. That number, the company said, is now doubling every year.

As it turns out, Google has been hard at work rewriting the Kotlin compiler from scratch in recent years. That new compiler, which promises to be faster and offer better interfaces to allow IDEs to improve features like better code hinting and static code analysis, is now in beta and will likely ship next year. Since the company has devoted quite a few resources to this project — and is currently maintaining two compilers in parallel — that means the development of the language itself has slowed down a bit.

“We’ve intentionally kind of slowed down the rate of change in the language because we’ve got the two compilers going in parallel,” Ward said. “Once we ship the new compiler and everyone gets on to it, then we’ll be able to then invest more into new language features.”

Among those new features are context receivers, which are currently still behind a flag. These will allow developers to pass parameters to a function, for example, to only write some of the code and values for connecting to a database once and then use this same context again every time you need to make that connection again.

As for the Kotlin Foundation, it’s worth noting that until now, only Google and JetBrains were members here, and the two companies used the foundation to coordinate their investments into Kotlin. But Ward explained that the two companies are looking to expand the foundation with new members. “We have a plan to expand beyond that,” he said. “That’s core to growing the Kotlin ecosystem: growing the Kotlin foundation beyond just the two companies that are the founding members.” He noted that the two companies didn’t yet have a reason to bring the Foundation under the umbrella of an organization like the Linux Foundation, in part because with two members, that would’ve been overkill, but that may change as Google and JetBrains bring on more members over time.

This article was originally published on Read More on their website.

Leave a Comment