Is kotlin MPP different than Kotlin Native?
Asked Answered
V

1

11

I have read multiple contents online but still not able to understand that is there a clear difference between Kotlin multiplatform mobile vs Kotlin Native?

Versus answered 23/6, 2021 at 16:39 Comment(0)
G
26

Yes, these are different things.

Kotlin source code can be compiled to different target platforms. The technology for sharing code between platforms is called Kotlin Multiplatform (or KMP).

Kotlin/Native is one type of target platform. For this type of target, Kotlin code is compiled into an LLVM intermediate representation and eventually into native binaries. Technically speaking, there are multiple native targets because you could compile for Windows, Linux, macOS, iOS, WebAssembly etc. through LLVM.

That said, there are other target platforms like JVM, JavaScript, Android, and even WebAssembly directly without LLVM (although that's under development).

Kotlin MPP (multiplatform project) more generally refers to projects that compile to several different target platforms. For instance, a single project can be compiled to the JVM, JS, and one or more native targets. In a way, a Kotlin/Native project can be considered multiplatform if it compiles to different native targets, but usually "multiplatform project" implies also other targets than Native ones.

KMM (Kotlin Multiplatform Mobile) is a deprecated product name that used to refer to a specific case of multiplatform project where the targets are Android and Native iOS. The iOS part of KMM projects uses Kotlin/Native, but not the Android part (unless it's using the special Android NDK target). The special name was there because the Kotlin team focused on this most common use case (of sharing code between mobile platforms) for a while, but later decided to unify the naming:

we are deprecating the “Kotlin Multiplatform Mobile” (KMM) product name. From now on, “Kotlin Multiplatform” (KMP) is the preferred term when referring to the Kotlin technology for sharing code across different platforms, regardless of the combination of targets being discussed.

Granlund answered 23/6, 2021 at 16:49 Comment(6)
@Joffery, thanks! It clarified most of my doubts.Versus
Just adding that as of now WebAssembly is still one of the native targets, and a future separate WebAssembly target is still under development.Soulier
@Soulier correct, I just wanted to keep the post simple (and kinda future-proof :) )Granlund
Do valid Kotlin native Code and Libraries also compile to the other targets? If not, where are the differences?Thermionic
@Thermionic please create a separate question if your comment is not related to this answer specificallyGranlund
With the introduction of KMP, it has become increasingly difficult to create and maintain pure Kotlin/Native projects (like CLI tools, native linux apps). They appear to be focusing on their GUI stuff (Compose) and server side (JVM) as well as KMP (Android/iOS) but everything except JVM seems kind of half-baked.Electioneer

© 2022 - 2024 — McMap. All rights reserved.