Menu

New compiler and new language features: how Google is going to develop Kotlin

TechCrunch spoke with James Ward, Kotlin Product Manager at Google, to learn about the role of language in the Android ecosystem and beyond, as well as the company's future plans for it. DOU retells key theses.

It's been more than five years since Google first announced that it will support Kotlin, a statically typed language for the JVM first developed by JetBrains, as a language for writing Android apps. In 2018, Google and JetBrains teamed up to launch the Kotlin Foundation. In 2019, the company took another step forward — Kotlin became the language that should be preferred when creating Android applications.

Google hopes that eventually all Android developers will switch to Kotlin.

"There's still a lot of Java on Android. We know that developers are usually more satisfied with Kotlin than Java, because this way the work is more productive and the quality of applications is higher. It would be great to get to the point where everything is completely on Kotlin," Ward said.

It has not yet been possible to do "all Kotlin", because the Java ecosystem is very large and has significant power. Thanks to Kotlin's compatibility with Java, developers can combine libraries, but to get all the benefits of Kotlin, they must remain in the Kotlin ecosystem. And despite all the attention paid to Kotlin, it is worth noting that the core of the Android platform and its API are still built in Java. Currently, there are several Android libraries written in Kotlin, but this is obviously only a small part of the overall platform, the article says.

Today, Kotlin is much more than just Android: Google's internal codebase already has more than 8.5 million lines of Kotlin code. This number, according to the company, is now doubling every year.

In recent years, Google and JetBrains have been working to rewrite the Kotlin compiler. The new compiler should be faster and offer better interfaces to allow the IDE to improve somewhat, such as code hints and static code analysis. The development is currently in beta, and it is likely to be introduced next year.

Since the company has allocated a lot of resources to the new compiler — and now supports two compilers in parallel — this means that the development of the language itself has slowed down a bit.

"When we introduce a new compiler and everyone gets the hang of it, then we can invest more in new language features," Ward added.

Among the new features of the language, in particular, context receivers, which are still in development. This update will allow developers to pass function parameters, for example, only once to write a piece of code and values for a database connection, and then use the same context again each time a connection is established.

So far, only Google and JetBrains have been members of the Kotlin Foundation, and both companies have used the foundation to coordinate their investments in Kotlin. But Ward explained that they are looking to expand the Kotlin Foundation.