What is KMM? Why is it Native and Cross-Platform at the same time?

Umair Khalid
4 min readApr 9, 2022

--

Hello Folks,

I am going to start a new series on KMM for mobile and web platforms and this is going to be the very first article of that series.

As the name states, today I am going to explain to you, what Kotlin multiplatform is and its importance in the software industry.

There are many SDKs and techniques available for cross-platform application development but there are some properties that make KMM stands out.

What KMM is?

KMM is a multiplatform technique used for developing applications for not only mobile (iOS, Android), SDK supports Web and Desktop applications by using an amazing code sharing mechanism that allows each platform to develop its own UI and use a shared codebase that makes KMM very practical solution for developing enterprise solutions by sharing common codebase among all platforms.

If you already follow clean code and modular programming approaches, it's super easy for you to adopt KMM coding structure and it promotes writing independent modular code that can be maintained, run, and tested in isolation.

If this information is not enough to understand KMM, I’d suggest reading this article.

Role of Kotlin

Kotlin is one of the most advanced and modern languages of this era due to its many advanced features which makes it very popular. When Google announced Kotlin as the official android development language and then spring boot provided Kotlin support takes this language to next level of fame.

When a language is hot, it’s easy to find community support, libraries, and learning material.

So KMM is heavily dependent on Kotlin as many parts of KMM architecture use Kotlin libraries which are platform-independent. For example for networking, Ktor is used and shared between platforms to make it commonly available for all platforms so you don’t have to worry about each platform using its own library and repeating all networking-related modeling and mapping strategies on all platforms. Isn’t it a life saver?

Why KMM is a real and practical cross-platform solution?

Support for multiplatform programming is one of Kotlin’s key benefits. It reduces time spent writing and maintaining the same code for different platforms while retaining the flexibility and benefits of native programming

Previously it was really tough to design an enterprise application with existing technologies, it was tough to write those applications which heavily relied on low-level APIs.

For example, if you have a use-case that is using media APIs and you are writing this application in cross-platform technology like React Native or Flutter, you used a third-party library, that third party will be writing two different projects in abstraction for you to achieve media usage. After a few months, iOS came with an update that was required in your next play store submission but wait!! You are using a third-party library that was written by a developer who is no more maintaining that library or he is not aware of that update or somehow is not free to provide an update. Now you are in trouble and can not submit the application due to third-party dependency.

There are a few other cons for example

  1. You are not aware of the quality of code written in third-party libraries
  2. Sudden API change can break your code
  3. Code performance
  4. Opensource code unavailability

A solution to the above problem is to develop and maintain your own library but it takes you to native development.

Now if your application is logic heavy and depends on low-level APIs a lot then you can compromise shared UI and use shared use cases among all platforms and enjoy native applications.

If you want to study some case studies then please check this amazing collection

Conclusion

KMM is one of the very few SDKs which provides native apps by sharing common code among platforms which makes it unique. It's a great SDK if you want to develop an app that heavily depends on low-level APIs and you are writing logic-heavy apps and supposed to repeat that code on all platforms then it's great to look into KMM.

--

--