DEV Community

RockAndNull
RockAndNull

Posted on • Originally published at rockandnull.com on

Why Kotlin Multiplatform could change everything in the mobile dev world

Why Kotlin Multiplatform could change everything in the mobile dev world

There have been countless approaches to cross-platform development over the years. A long time ago Java promised to "write once, run everywhere". It's a promise that was mostly left unfulfilled.

Don't get me wrong, there are many respectable technologies out there that achieve this promise to a very decent degree in the mobile world.

Take for example Flutter. In my opinion, the framework is as close to the cross-platform promise as any other. Literally, to add a new supported platform to the Flutter ecosystem, the Flutter team just needs to be able to draw to a canvas. This allows them to literally "write once, run everywhere". But even this approach of course has drawbacks. It's the same-looking app that runs on different platforms. On every platform, it feels "alien".

Other approaches, like React Native, choose to call native UI components to make the app feel "at home". Unfortunately, this has drawbacks as well. The complexity of the framework increases exponentially, and the framework team is in a constant catch-up race with the native platform while they are making changes to their native UI components, and subsequently breaking the cross-platform framework.

Now there's a new kid in town. Kotlin Multiplatform (KMM) - along with Compose Multiplatform (CM) - promises to offer something that it has never been offered before in the cross-platform world (OK maybe it was tried at least once in the past). Up until this point, you could have good enough apps for every platform when using a cross-platform framework. If you wanted to have apps that feel "at home" you would have to take the native way. With KMM the promise is that you can have a native app in one of the major platforms (Android) and a good-enough app for the other major platform (iOS).

Also, the risk of adopting KMM+CM is significantly lower than any cross-platform technology. With Flutter, ReactNative, Xamarin, and others, if their maintainers decide one day that they no longer want to continue their development, you would be left in a messy situation where you would have to either re-write 2 native apps or choose another cross-platform framework (along with their different quirks). With KMM+CM, even if Jetbrain decides that this whole cross-platform experiment isn't worth it, your Android app would still be supported (since it's the official language and UI framework for Android).

Having shared my excitement for the Kotlin Multiplatform and the upcoming Compose Multiplatform technologies, I would need to note that both of these technologies are not marked as stable yet. KMM is almost stable, but for CM is still early days. But the potential is there. You might be able to write UI and business logic in Kotlin for your Android app, and easily port it to iOS to kick-start your app journey. When the app becomes big enough (and you choose so) you can write a native iOS UI and still share the business logic between the 2 apps.

Hopefully, what I described above could soon be a real-world scenario and not just daydreaming :)

Happy coding!

Top comments (0)