At Passenger, we constantly appraise new technologies to make sure we keep pace with the best solutions and create as effective a product as possible. This purview includes new software languages like Kotlin. Here, we explain what Kotlin is, why we’ve invested in it, and what it means for the Passenger experience on Android devices (hint: it’ll be even better).
There are few worse sins in the world of technology than standing still and staring down at your feet. The industry innovates fast – those responsible for a product must be aware of what’s coming to prevent either falling behind the pack or plunging down otherwise avoidable pitfalls.
At Passenger, we keep pace to avoid troublesome situations arising due to outmoded or obsolete tech. And that’s why, ever since official Kotlin support was announced at Google IO in 2017, we’ve been looking to make use of this fantastic new language in our Passenger codebases.
Why? Because Kotlin can make Passenger on Android a faster, slicker and all-round cooler experience.
Here we explain what Kotlin is, why we adopted it and what it means for our customers.
What is Kotlin
Kotlin is a powerful and nimble programming language that has existed since 2011. We’ve monitored the development of the language from afar, as the lack of official support for Android development was a cause for concern. (You’ll have the rug pulled from under your feet if you invest hundreds of hours in new code, only to find that its development is suddenly discontinued.)
Thankfully, Google saw the light and announced official support for the language in 2017, even going so far as to create a foundation with its developer, Jetbrains, to drive Kotlin’s growth. That gave us the confidence to dive into Kotlin and start eking out new benefits for our users.
What makes Kotlin so good?
Since Android, Google’s mobile operating system, entered the scene, the primary development language used has been Java. Java is good as the syntax is very easy to understand and programmers can write code once and deploy to many different environments. This versatility is one of the many reasons why Android has become so successful.
But there remain drawbacks. For one, Java is a privately owned and patented language by Oracle, who went through a very lengthy and expensive lawsuit with Google over disputes on uses of Java APIs. Another more technical drawback is that Java is an older language that has sometimes lagged behind others in adding new features.
With Kotlin, you get the best of both worlds. Not only can you write Kotlin along side your Java code (making it easy to transfer information) but it comes with all the bells and whistles of the more modern programming languages. It also enables us to:
- …reduce our code size: compared to Java, Kotlin code is at least 40% smaller, which makes for much easier coding
- …see the result of code in its final layout, which reduces the guesswork required when just looking at lines of code
- …use lambdas (functions that make code development much more efficient)
- …create more robust, reliable code via a stricter, but more dependable, programming approach (one that circumvents what is probably the number one cause of crashes on Google Play)
What does all of the above mean to our customers? It means that Passenger on Android will be an even more optimised, smoother and more seamless experience. Better code also means reclaiming time working on bugs, which in turn means more time to get on with creating new, exciting features!
How are we utilising Kotlin in the Passenger codebases?
Passenger does a lot, so as you might expect its codebase is rather large. The software is built on 13 different framework libraries, each packed with countless features.
Nevertheless, as Kotlin is such a flexible language, writing new features into the Passenger codebase is super-easy to do. So far, every new feature, such as Passengers’ new Disruption module, the Live Buses feature, and the new Favourites section, have all been written in Kotlin, while bug fixes or existing features have remained in Java.
Slowly but surely, we’ll be converting existing code into Kotlin, while continuing to write brand new Kotlin code alongside it. Naturally this will take time, as we want to be careful not to disrupt the customer experience or quality of the Passenger product.
It’s a slow but certain task – one that will result in gradual, continual improvements. Passenger’s end users will reap the rewards over the coming months.
Further reading