At the Google I/O keynote, the Android team announced first-class support for Kotlin. Many developers were very excited about this announcement because it means that working with Kotlin on Android will be a much better experience. It’s also an indicator that Kotlin, the nascent language built by JetBrains, will be around for the foreseeable future.
To me, official support for Kotlin shows that Google believes that this is the future of Android development. I suspect we’ll see a much wider adoption of Kotlin over the next year, and in the years to come.
Kotlin is a language that was developed to have everything you love about Java but without all the verbosity and boilerplate. In this article, I enumerate some of the benefits of using Kotlin in your Android projects.
There are many oft-cited benefits to adopting Kotlin, but here I focus on:
- Fast language releases
- 100% Java interoperability
- Active, and growing community
- Continuous Integration with Kotlin
These benefits are sometimes overlooked, but I believe them to be key factors in why Kotlin is here to stay.
Benefits of using Kotlin
1. Fast Language Releases
As an Android developer, this is what I expect from a language: to evolve quickly, to be backwards compatible, to come with a suite of modern features and be supported by a team that listens to what the community needs. JetBrains is doing surveys to provide not only what they think is best for the language, but to hear about what the community wants from the language.
For example, there’s this June 2017 survey where people all around the world provided feedback of the most desired language features, among other questions.
2. “Just another language” - 100% Java interoperability
I read this phrase in some posts, mailing lists, and other threads where people don’t really see the benefits of having a new JVM language like Kotlin. This would be true if Kotlin were the same as other JVM languages. However, Kotlin was created with a different purpose than Scala or Groovy. The main differences lie in the following key features:
It’s 100% Java interoperable. Despite the fact that other JVM languages tried to accomplish this, it’s well known that there are issues to really bind those languages with the Java world in certain scenarios, especially for the Android ecosystem. For Kotlin this is not the case as it guarantees that it works transparently with Java.
It has a small runtime size (~859KB). This is another aspect that makes a big difference when compared to other JVM languages (like Scala and Groovy at ~6MB). Being 100% interoperable with Java, Kotlin isn’t required to have its own types like Lists, Maps, etc.; all of them are already inherited from Java.
Being statically typed means that the IDE is able to suggest what the user is trying to accomplish, by analyzing the context and warning the developer about possible mistakes; all possible because it’s type aware. Try seeing what Android Studio suggests when editing a Gradle Groovy file, and observe the auto-complete feature; its suggestions are totally useless, but it’s understandable as Android Studio doesn’t know what types you are dealing with. Static typing is why Gradle is now incorporating Kotlin to configure your Gradle files. You can learn more about this here.
3. Active, and Growing Community
Despite Kotlin being a relatively new language, the community is extremely active, and growing fast. Below are some of the most useful channels I’ve found for connecting with Kotlin developers. Should you have any questions about Kotlin, feel free to connect with me directly, or raise your questions here:
- Slack Channel (~7000 members as of May 2017)
- Kotlin Forums
- Kotlin Nights
- Upcoming Talks
- Kotlin for Android
There’s also a huge Kotlin Conference happening this November 2017 — you can check out the great lineup here!
4. Continuous Integration with Kotlin
Last but not least, Continuous Integration (CI) is a common best practice used by thousands of development teams building Android applications. CI systems automatically kick off new builds and run your team’s tests with each commit, to ensure that no potentially breaking changes make it into production.
Mobile-first CI systems, like buddybuild, make it easy to setup and maintain a development pipeline for your Android projects, allowing you to iterate on your projects faster than ever. I use buddybuild as my continuous integration and continuous deployment system because, similar to Google, it has first-class support for Kotlin.
In just a few simple steps, and without adding a single line of code, I have a complete CI/CD solution for all of my projects. In my many months of using the service, buddybuild has been consistently reliable and always available. It has proven to be an excellent tool that allows me to experiment building apps written in Kotlin and helps me take my Android applications from source code to Google Play.
Following Google’s announcement about official Kotlin support, we’ve already started to see an increase in the popularity and adoption of the language. I expect we’ll continue to see an increase in adoption in the years to come.
It’s exciting to see the advancement and evolution of this language, as well as the surrounding community. Using Kotlin has been transformative to my Android development and, when paired with tools like buddybuild, I’m able to iterate on my projects faster without sacrificing the quality of my codebase.
If you’re interested in using Kotlin for your next Android project, feel free to follow my series to learn how! In this series, you’ll learn how to use Kotlin to develop an Android App from scratch and using libraries like Dagger2, Retrofit, RxJava, RxAndroid, and more.