The Case for Kotlin
Zach Arden
Zach Arden

The Case for Kotlin

Zach Arden, Android Engineer

Traditionally, when people think Android development, they think Java. But since 2016, many dev teams have been switching to Kotlin, one of the newest, most promising programming languages available. JetBrains, a Czech software development company, launched their Kotlin project in 2011 as an answer to deficiencies they experienced in other languages.

The Need for Something Better
It started when they were looking for a replacement for Java. The JetBrains team kept running into issues coding with the language, and there wasn’t any promise of the updates they needed. So, they started looking at other options. After running into comparable issues with other languages, the light came on and the JetBrains team decided to try to build something themselves. It had to be practical and would retain some of the best features of other languages available, with great support. An added requirement was Java compatibility since so much of JetBrains’ code base was written in the language.

JetBrains launched their project in 2011, and Kotlin was born.

Initial Challenges
As Kotlin developed, one of the greatest challenges was the nullability in the type system. Creating features that interact with Java’s interop but don’t have a direct analogy within the language are difficult to implement. The question became: how do you assign Java methods being used in Kotlin?

It wasn’t practical to assume nullability for Java parameters and return value, so designers tried supporting manual nullability annotations on Java APIs while running automatic inference by analyzing the bytecode. But this wasn’t enough. Maintaining external annotations wasn’t practical either, and automating the process reduced accuracy. Finally they decided to implement platform types, which solved these issues and is still what Kotlin uses today. They implemented a similar mechanism for mutable/ immutable collections and Java APIs.

The Google Effect
Once JetBrains launched Kotlin, a few teams heard about what was happening and word started to spread about its usability. Dev teams here and there have been building with the language for a while, but its use really took off when Google announced first-class support for Kotlin on Android in 2017. This was the first time a new programming language had ever been added to Android. Taking it a step further, Google partnered with JetBrains to launch a nonprofit foundation for the language.

With the Google endorsement and new status as official Android language, Kotlin’s visibility and user base expanded rapidly. Teams are still learning to adapt, but it’s only a matter of time until more and more companies make the switch.

Prolific Gets in the Game
Prolific has been an early-adopter of sorts, implementing Kotlin for our Android projects since Google’s announcement. Our first app built entirely using Kotlin was released that same year,

The most recent example is the app we built for the CrossFit Games, on both iOS and Android. It was a native codebase for both, so we used Kotlin to write everything. Kotlin made writing the app quicker (fewer lines of code), easier (language lifts more for us), and made the app more stable upon release because the language allowed us to write code with fewer bugs.

Among other features, the app allows for stat lookup– the user can search for statistics about the CrossFit Games across a selection of criteria. Users can also keep up with the Games as they unfold, as CrossFit releases new exercises through the app every week while the Games are live. We saw large spikes in traffic each time a new exercise was released.

Where Kotlin Goes From Here
Kotlin is slowly revolutionizing Android development, making it easier for teams to write faster and more efficiently. It’s a pleasure to use, and implementing it in our team has ultimately meant that projects are completed more quickly and accurately. A win for the team and our partners.

If you’d like to read more about the case for Kotlin, Dan Lew wrote a great piece about it here. And for examples of other apps built with Kotlin, Android’s website has a list to check out.

Have questions about Kotlin or want to learn more about how Prolific uses it? Contact us. Send us your questions via our Connect Form.