Search code examples
kotlinkotlin-multiplatformkotlin-native

Is kotlin MPP different than Kotlin Native?


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?


Solution

  • 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.