Should I learn Kotlin for Android and other FAQs

Florina Muntenescu
Android Developers
Published in
4 min readNov 3, 2020

--

Ever since we announced our Kotlin support in 2017 we’ve been getting a lot of questions about Kotlin on Android: you wanted to know whether it’s time to learn it, to introduce it to your app, what the best course or tutorial to learn Kotlin is, whether Google is using Kotlin internally and what our plans for the Java programming language are. In this post, I want to answer some of these questions.

Q: Should I learn Kotlin for Android?

The questions we get most often are on the same line:

  • “What should I choose to learn between Kotlin and the Java programming language for a beginner?”
  • ​”I’ve done the basics of the Java programming language, is it the right time for me to switch to Kotlin for Android development?”
  • “For an old time Java developer wanting to learn Android development, do you recommend going straight to Kotlin or learning in Java?”

Short answer:

Yes! Start learning and using Kotlin!

Long answer:

Kotlin & Android

In 2017 we announced Kotlin support at Google I/O. That’s when we started making the first steps towards ensuring that our APIs, docs and samples are Kotlin friendly. In 2019 Android became Kotlin-first, so we started relying even more on Kotlin features. As an example, Coroutines became our recommended solution for running asynchronous work. Here’s what else we’ve done:

Kotlin-first libraries

We started by adding first class support for Kotlin Coroutines to several of our Android Jetpack APIs, like Room, LiveData, ViewModel and WorkManager, transforming the way we do async operations on Android. The Firebase Android SDK and many Jetpack libraries have Kotlin extension libraries (KTX) to make using them even more fluent with Kotlin.

Now, many of our libraries such as Paging 3.0 and DataStore are Kotlin-first. Jetpack Compose, our new, unbundled, declarative UI toolkit, is written from the ground up in Kotlin.

Tooling

Development productivity comes from great tooling. As such, we’ve been making many improvements for Kotlin to the compilation toolchain, including enhancements to the Kotlin JVM compiler, Kotlin-specific R8 optimizations, and even developing new tools like Kotlin Symbol Processing. We’ve added built-in Android Kotlin Live templates, which allow you to use shorthand to add common Android constructs to your Kotlin app. At the same time, new Kotlin-specific Lint checks help you make Kotlin code more language idiomatic. This is especially useful as you’re transitioning from the Java programming language to Kotlin.

Q: Is Google using Kotlin internally?

Within Google we’re also doubling down on Kotlin. Over 60 of our apps (like Google Home, Drive, Maps and others) have added Kotlin to their codebases. Our large internal codebase counts over two million lines of Kotlin code.

Q: Should I migrate my app to Kotlin?

We often get this question, but the answer here depends on you. If you’re happy with your current codebase and tech stack, are proficiently using your solution for managing async tasks, and have an efficient way to catch errors, migrating may not be the solution for you

If you like what you’ve seen with Kotlin from either trying it or learning the language through some of the courses mentioned below, and you also want to take advantage of the latest Jetpack APIs, then you should consider adding Kotlin to your app. One of the advantages of Kotlin is it’s great interop with the Java programming language. You can take small, incremental steps in adopting it — maybe first trying it out on tests, then on new features and then you can try converting some of the older code as you touch it.

To make your first steps towards migrating to idiomatic Kotlin check out our Converting to Kotlin codelab.

Q: What about the Java programming language in Android?

We added Kotlin support in addition to Java as they both compile to the same bytecode and can exist alongside each other. We love Kotlin for its expressive, safer way to write code. We continue to maintain and evolve our Java support as well. For example, in Android 11, we added support for a number of APIs from newer OpenJDK releases all the way up to version 13 and Android Studio even lets you use some of these APIs on all Android devices, regardless of their OS version. Read more about the support for newer language APIs here.

Q: What’s the best way to learn Kotlin?

Adopting a new language is not an easy task, but we’re trying to make it as easy as possible:

  • Get started with the training courses — they address developers of all levels, from beginners to pros, that will help you advance your Kotlin on Android skills, from Android Basics in Kotlin, a new online course for people without programming experience, to advanced tutorials that teach you how to use Coroutines.
  • All of our documentation pages contain Kotlin code snippets, so you can easily compare how our APIs work in both languages, and all of our samples have Kotlin versions.
  • Check out our articles and videos that teach you a wide range of Kotlin topics.
  • Read the guidance for developers and teams who want to switch to Kotlin on our developers.android.com/kotlin pages.

Since officially adding support for Kotlin 3 years ago, we’ve been stepping up to support this awesome language and ecosystem. Together with JetBrains, we’ve formed a foundation for Kotlin to ensure the language ages well, for example through a careful process for vetting breaking changes. Our contributions extend beyond that: Google has a team of engineers contributing to the Kotlin compiler as their full-time job, the Jetpack APIs we’re building are not only supporting Kotlin but they are Kotlin-first, and we’re committed to making Kotlin on Android a seamless experience.

Java is a registered trademark of Oracle and/or its affiliates.

--

--