In this article, we explore the features and advantages of KMM and Flutter – app development frameworks, we examine their approaches to cross-platform development, and discuss their suitability for different business scenarios. Join us as we delve into the realm of multiplatform app development and uncover the potential of these cutting-edge technologies!
What is Kotlin Multiplatform?
KMM, which stands for Kotlin Multiplatform Mobile, or generally KMP (Kotlin Multiplatform), is an open-source SDK provided by Jetbrains used for creating applications on different platforms using a single language, Kotlin. It enables the development of applications for mobile systems (iOS, Android), desktop (macOS, Windows, Linux), web applications, and backend.
The idea behind KMP is to extract the common parts shared among all platforms. And what can be extracted? In the so-called clean code approach, we can extract the entire domain layer and infrastructure. If we want to achieve a fully native UI, we can create it separately for each platform. The created views, i.e. presentation layer, can be connected with the common module that contains all the shared elements. This approach allows us to create full-fledged native applications faster and cheaper than the standard solution.
The next stage is Compose Multiplatform, which was presented at KotlinConf 2023 and is currently in the alpha phase. This solution allows writing the UI layer for other platforms as well using a single codebase, which is made possible by utilizing the Skia graphics engine, used also in another cross-platform solution called Flutter.
Flutter - quick recap
Flutter is a complete cross-platform solution where applications can be created for all platforms using a single codebase. There are no separate views in different languages or frameworks. Of course, we can create different versions of views for different platforms, but the elements we build with as well as the language itself are the same.
Is Skia a good solution?
We know from Flutter that Skia has its downsides. It lacks full support for Metal, the iOS graphics engine, which leads to various issues, such as the problem of initial animation loading on iOS. Currently, Flutter is transitioning to a new graphics engine called Impeller, which is much more advanced and modern. It has full support for Vulkan and Metal and includes 3D support. The performance improvements presented are also impressive. So, why is Compose Multiplatform moving towards Skia when the competition is heading towards new solutions?
Are KMM and Flutter competitors?
In my opinion, and in a nutshell, they are not competitors. Kotlin Multiplatform is an ideal extension of native solutions. Native applications can become less complex, resulting in fewer bugs. How? By extracting the logic layers into one place, we will have one source of truth, one business logic, one function, and thus a substantial advantage.
There are many pros from the client’s perspective:
The solution can be more stable.
It can be cheaper compared to developing two separate native applications, assuming the client wants native applications.
Another business example could be a situation where we have a native application for the Android system. In this case, there is a high probability that we can extract a significant amount of code to the shared part. If the client wants a native application for the iOS system, a team with SwiftUI skills can create the presentation layer. In my opinion, KMM is a good solution if we want to achieve native views with a shared business layer, making development process easier.
What about Flutter?
Flutter is a fully hybrid and cost-effective solution where we write shared code for both platforms, essentially from scratch. Flutter has all the advantages of KMM and even a few more. If we don’t need a “true” native application from a business perspective, it is still the best solution on the market. The entire codebase, including the UI, is shared.
What does it look like?
Currently, KMP support for libraries that work on both platforms is limited. Like any emerging technology, it needs time to develop.
In conclusion, currently KMP is not a competitor to Flutter. In my opinion, it will be an extension and facilitator for building native solutions, not fully hybrid ones. In the future, it may become a more cross-platform solution, but it starts off relying on older approaches. It will take time for it to become a fully-fledged solution.