Native Technologies

Why use Kotlin on your Android project?

In 2019, at its annual I/O conference, Google officially announced “Android is now Kotlin First” and instructs developers to use this language rather than Java. Two years later, where are we? What are the reasons for using Kotlin on your Android project?

| Kotlin becomes Google's favorite language for Android

google_kotlin_announce

Source: Developer Keynote (Google I/O '17)

Support by Android Studio: we couldn't ask for better! ?

Kotlin is a language developed by JetBrains. The publisher promotes the use of Kotlin by providing a great support in its IDEs. Is it any wonder that by attracting new developers to the Kotlin community, JetBrains is generating more paid licenses?

JetBrains brings to Google and Android Studio THE best Kotlin plugin on the market.

A bigger and bigger Kotlin community?

Two years after Google adopted Kotlin, +50% of the top 1000 apps on the Google Play Store use Kotlin code! That doesn't mean they're 100% written in Kotlin - you can have a mixed Java AND Kotlin application. However, the community is growing and JetBrains and Google are providing huge support to local communities through Kotlin-Everywhere.

In Paris, the next Kotlin Everywhere meeting will take place on October 19! If you are interested in Kotlin, this is THE annual event not to be missed: https://everywhere.kotlin.paris/

By providing financial assistance to meeting organizers in order to create conferences around Kotlin and its uses, and by encouraging their experts to travel all over the world to do talks, JetBrains and Google really want to boost the adoption of the language.

top20_201906

Source: RedMonk Language Rankings over time: June 2019

Mission successful, Kotlin is the 4th trend language on The latest Stack Overflow report and appeared for the first time in RedMonk language ranking in 2019.

So much for business considerations, but what about the technique?

Less code, better quality, fewer bugs?

For The BUX app for example, a Kotlin file is 28% smaller than a Java file. Less code, more idiomatic = less bugs, less maintenance, fewer lines to test and type.

| So the most important thing: we're writing less code.

More idiomatic, Kotlin brings a better Dev-experience. Some key concepts - Extenders Functions, Immutability, Null-Safety - make the use of this language a real pleasure.

AndroidX, JetPack and the Coroutines?

Google has rewritten most of its Android APIs in its libraries prefixed with ++code>androidx++/code>. These libraries are part of the Android JetPack suite and provide support primarily to Kotlin... including the Kotlin Coroutines! Coroutines allow “blocking” tasks that would slow down the main UI thread to go into the background. The new AndroidX APIs open the doors to a syntax that is very easy to use to perform background tasks in an optimized way.

Bonus: we can refactor Java code as we go

You don't have to wait for your next project to use Kotlin. You can use Kotlin on new features in your app that was originally coded in Java. This is the approach used by Tinder, Airbnb and Deezer. File by file, rewrite your features in Kotlin and test it: you can continue or retrace your steps. To train you, a CodeLab Google is available.

Do you use Kotlin to make your Android Apps? Do you see other major benefits? Leave a comment, I am very interested to know what uses you make of Kotlin in your Android apps??

In the meantime, maybe we'll meet at the next Kotlin Everywhere? https://everywhere.kotlin.paris/

Do you want to stay up to date with the latest tech news and innovation? Read the latest issue of BAM Innovation Lab on app clips, and subscribe to stay up to date!

Développeur mobile ?

Rejoins nos équipes