News & Views

Can’t Help Falling in Love…with Kotlin

Have you wondered about what Kotlin is and how it has changed the development space for mobile and other platforms? At Vectorform we adopted Kotlin early in its life cycle, and are tracking new capabilities that the language introduces.

?: All Shook Up

Conversations around programming languages normally only take place between the geekiest of geeks. However, when working on new machines, platforms or tech systems, even the people who don’t have to do any programming will often hear about the promise of a new or updated language for writing computer code.

Over the past few weeks, we’ve had a few clients ask us about Kotlin and our experience with it. Those asking about it have heard about it as a new programming language. The aim of this article is to give non-coders an idea about what Kotlin is, what makes it stand out as a modern programming language, and how Vectorform has used it for over five years to write safe, performant code for our Android projects. More than that, we will also talk about what we see as the possibilities for the language as it continues to evolve.

?: Suspicious Minds

Kotlin, unfamiliar as a name for a programming language, would lead many people to think it is a newer language. However, Google announced first-class support for it as a programming language for the Android operating system in 2017, and its development goes back much further. JetBrains released its first version of the language in 2011 as a language for Android and Java Virtual Machine environments. It offered interoperability with Java projects and, even before Google elevated its status for Android, JetBrains was supporting Kotlin early in its lifespan. In 2015, Vectorform started to explore it as an alternative to Java for Android development.

Along with Apple’s Swift, Kotlin raised the bar by providing a language that was crafted from the beginning with the goal of helping developers avoid the most common mistakes in programming. The language makes memory management and data safety a primary concern, encouraging patterns that ensure data is available to use when the programmer expects it to be ready. Java, as a high-level programming language that came from the C family of languages, inherited C’s basic patterns for dealing with memory management which required the programmer to request, then verify, if memory could be allocated for use by the program. Java requires the programmer to then decide, when memory couldn’t be allocated, to decide what to do when these situations occur. Also, the programmer had to check and make sure that memory has not been freed by another part of the program. If these checks are not done, the application will crash when a problem arises. Checking for these situations requires a lot of boilerplate code that was too often an afterthought for developers. Kotlin, Swift, and other modern programming languages have all tried to find elegant ways to warn and avoid issues like this. Until Android adopted it as an official language, though, it was difficult for anyone writing production-level code to feel comfortable shipping a project with it.

Taken from the perspective of an Android developer, Kotlin has been a language that is incredibly safer to use. Crash reports on deployed applications have decreased significantly when the safe coding practices are followed. And as Android (as a platform) expands into wider spaces, it also means that developers that use Kotlin on Android can work on projects on other platforms that Android supports (such as Android Automotive). Since Android is based on Linux, and Java environments are common across computing platforms, this also means Kotlin can be utilized in those areas as well (embedded systems such as Raspberry PI, for example).

?: Treat Me Nice

Another huge benefit to Kotlin as a mobile programming language comes from Swift’s similarity to it. While Swift was introduced by Apple as a ready-to-use language in 2014, the similarities to Kotlin and the timeline of its development make the similarities between the languages feel intentional. The safety features between the two, and most of the language syntax, are simply too close to be coincidental. While Swift may have had a brighter light shown on it when it was revealed, Kotlin was in the world first and it would be a mistake to think that Kotlin was copying Swift. More than likely, Swift was seeing how Kotlin solved several problems relating to writing safe and expressive code, and the team at Apple incorporated what they saw.

At Vectorform, we have been using Kotlin for all new Android development since 2017. Because of Kotlin’s similarity to Swift, we have been able to build our mobile team’s approach to developing applications by taking advantage of these similarities. Most of our mobile team works comfortably on both platforms, and in many cases, a problem that has been solved on one platform will inform – if not be 90% similar – to the solution on another. We have taken advantage of this by creating a unified architecture for our mobile development that lets us best learn from each other across the mobile operating systems. Also, simply put, it is an enjoyable language to use. It lets us write clearer, more concise code and we can use the best parts of object-oriented programming as well as functional approaches to operating on data.

Kotlin’s development and platform expansion has not stopped and there are several technologies that JetBrains is working on to make its adoption even larger. Kotlin can now compile with the LLVM compiler, enabling native interactions with iOS devices, as well as the ability to run as a web-based environment. In the coming weeks, more articles will be published that talk about how we at Vectorform have taken advantage of not just the similarities between Kotlin and Swift for our mobile team, but are exploring advances with Kotlin to further consolidate coding efforts in our development projects.

Looking Ahead

We have a number of articles lined up that will shine a light on our experience with Kotlin on Android projects, as well some information and examples of new features that JetBrains is helping bring to the language. These will include how we take advantage of the similarities between Kotlin and Swift, how we use these similarities to help architect our mobile applications, and the possibility of using Kotlin to drive parts of cross-platform mobile development.

In the meantime, contact us if you have questions or are interested in learning how we can help you integrate Kotlin into your projects!

Related News & Views

Interested in learning more? Let’s start a conversation.