Compose Multiplatform
visit websiteCompose Multiplatform is a declarative framework for sharing UIs across multiple platforms with Kotlin. It is based on Jetpack Compose and developed by JetBrains and open-source contributors.
You can choose the platforms across which to share your UIs using Compose Multiplatform:
(as of may 2024)
Why do we adopt this technology?
Having experience with Jetpack Compose (for Android), it is a very small step to Compose Multiplatform. We noticed that with very minor changes we can make our existing Android-specific code run on other platforms, like iOS. With only a minor setup change, our newly written UI is now reusable on a variety of other platforms.
Related technologies
Jetpack Compose
Jetpack Compose is a modern toolkit designed to simplify UI development. It combines a reactive programming model with the conciseness and ease of use of the Kotlin programming language. It is fully declarative, meaning you describe your UI by calling a series of functions that transform data into a UI hierarchy. When the underlying data changes, the framework automatically recalls these functions, updating the view hierarchy for you.
Kotlin Multiplatform
Kotlin Multiplatform (KMP) is the ability to write pure Kotlin code (meaning having no platform specific code in it), combined with platform-specific Kotlin code, and run this on multiple platforms. This is done with the help of Kotlin/JVM to target JVM platforms (like Android), Kotlin/Native to target native platforms (using a LLVM backend, targetting platform like iOS, macOS, Windows,..), and Kotlin/JS to use in javascript codebases.
We already know from tools like Flutter and React that using the same language for multiple platforms is a big advantage. One of the disadvantages of these tools is that combining them with native code isn't that easy. Since Kotlin compiles/transpiles to actual native code, interop is as easy as mixing Kotlin with Java on Android.
Note that KMP isn't a cross-platform framework which forms the base of your app. It's better to compare it with an additional library you add to your existing native app. The developer itself is in charge of how much code is shared between platforms, ranging from a single method to the whole app. Multiple official and community-backed libraries are available to ease development, from API calls to storage to UI development (like Jetpack Compose).