img

Introduction to Kotlin Multiplatform

Introduction to Kotlin Multiplatform

Using the Kotlin language to program logic that can be used on all platforms of your app, it creates common logic that the native UI of any app can call upon.

KMP is really about pragmatic programming to help meet the growing demand to develop mobile applications on multiple platforms – a clean, clear way to avoid having to write the code twice.

The philosophy that has driven Kotlin since its inception is about enabling developers to code for all platforms. Kotlin is a modern language that allows you to develop applications more cohesively, and dovetails with native platforms on Java, iOS, and the web, so you can build on what’s already been coded. You focus on sharing code that is data, business, or presentation logic, and leave platform-specific components to be implemented natively.

It’s important to note that multiplatform does not mean compiling all code for all platforms. In mobile app programming, for example, you determine which modules are platform-specific and which are common to Android and iOS. Those which you identify as common to both can be programmed using KMP, writing in Kotlin Native.

KMP is a low-risk way to avoid repeating logic to develop applications for iOS and Android more expeditiously and effectively. Ultimately, KMP leads to better code overall. And it’s one of the many reasons why Touchlab is now fully committed to Kotlin as the most viable way forward for development teams today.

As a programming language, Kotlin keeps growing in popularity throughout the world, and with the introduction of Kotlin Multiplatform (KMP), there’s been more and more chatter among the mobile developer community about the possibilities it can bring.

Users’ needs are the same, whether they’re using an Android or an iOS device. Development teams, however, remain siloed by discipline, whether they’re programming for web or Android or iOS.

So, as a software development team, you have some challenging questions. Can you provide consistent quality on all devices when you have different development teams with varying skillsets developing the same apps for different devices? And can you ultimately justify the amount of time, budget, and resources it takes to produce viable solutions? We believe KMP is the best possible way to answer to these questions.

KMP: ready right now

It’s madness, really. An app is written for the web. Then for Android. Oh, and then it needs to be written for iOS, too. (At the same time.) Same app, different code. The question is, “Why?”

Development teams are essentially tripling their coding and testing efforts to ensure multiplatform coverage. It’s costly. It’s time-consuming. And – this might be the craziest part – it’s uncertain what the shelf-life of the code will be. As we know, the future is unwritten. As always, the goal is to be able to implement products more efficiently, and with better testing across platforms. And up to now, every multiplatform coding solution that has come along really hasn’t worked that well.

The good news is that there is now a better way.

And a proven way.

We at Touchlab have been writing code in Kotlin and deploying it to Android and iOS platforms, with no hiccups. That’s why we’ve gone all-in with Kotlin Multiplatform.

KMP is a true multiplatform language 

Kotlin enables you to write once, and test once. No siloed development teams. The same code can be used across Android, iOS and Web apps with no changes, eliminating the need for a translation layer. In essence, you’re reducing the amount of business logic coded by frontend developers by consolidating it efficiently with native code, but not oversimplifying abstractions. What’s not to love about that?

No wonder there’s a groundswell of enthusiastic support in developer communities around the world. There are 1.5 million developers currently using Kotlin, with 96,000 GitHub repositories containing 100 million lines of code. And the numbers keep growing. It’s one of the top two languages that developers are hungry to learn.

Kotlin was developed as a completely new language eight years ago, built from the ground up as a pragmatic approach to coding – a way to develop cleanly, clearly, and quickly.

Simply put, Kotlin is more readable, reusable, interoperable, and safer, offering a first-rate developer experience.

KMP for your complete tech stack 

It’s a low-risk way to code because it dovetails seamlessly with the native platforms on Java, iOS, and the web. It’s a modern language that enables you to build on what you’ve already coded, without re-working or re-inventing what you already have. Plus, because the code you share is optional, you can start small and increment as desired.

Kotlin is really an extension of Java, so it’s not a big leap for Java developers to start using Kotlin at all. In other words, you don’t have to make a big, potentially expensive decision to get started.

Kotlin is really an extension of Java, so it’s not a big leap for Java developers to start using Kotlin at all. In other words, you don’t have to make a big, potentially expensive decision to get started.

 

In fact, on Android, Kotlin was built for direct JVM interoperability. On iOS, Kotlin is ready for prime time, and the first half of 2020 will see rapid mainstream adoption. And Google officially recommends Kotlin as a language of choice.

The big considerations for any development team are cost, time, resources, and risk. And the big problem with the siloed approach is that organizations are often tripling them.

At the same time, the wrong teams are working on the wrong projects. Back-end developers should focus on architecture as well as APIs – but not UI. Enabling your back-end developers to code and test the client and server features as a unified whole enables more rapid development with safer, higher quality and identical implementation.

Our experience with Kotlin so far? No siloed teams. More streamlined workflows. Real cross-platform functionality.

Useful introduction to Kotlin Multiplatform resources