So I know Kotlin Native is obviously Native and Kotlin JVM isn't but is the code between Kotlin JVM and Kotlin Native: 1. Different Compiler and Different Code 2. Different Compiler and Similar Code 3. Different Compiler and Same Code 4. None of the above (please explain)
The Kotlin/JVM and Kotlin/Native compilers share the front-end (the part that performs code parsing, name resolution, type inference etc.), but the compiler back-ends that translate the internal program representation to the target code (the JVM bytecode and LLVM bitcode, respectively) are different.
The Kotlin language accepted by the two compilers is the same, but some of the features and checks are platform-specific. Also, the standard libraries for Kotlin/JVM and Kotlin/Native are sufficiently different, see the APIs available on each platform here: Kotlin Standard Library.
Another big difference is the memory model: Kotlin/JVM uses the Java memory model, while Kotlin/Native offers its own concurrency and memory model.
Also, the dependencies that one can use in Kotlin/JVM and Kotlin/Native projects are different. In addition to the projects built using the same Kotlin target:
Kotlin/JVM can also use any libraries built for the JVM (written in Java, Scala etc.)
Kotlin/Native can also interoperate with native libraries written in C (or at least having C headers) using the C interop tools.
Both Kotlin/JVM and Kotlin/Native can use Kotlin Multiplatform libraries. Given that a dependency is a multiplatform library, one can entirely reuse the code working with it between Kotlin/JVM and Kotlin/Native.
androidNativeArm64
, androidNativeX64
, androidNativeArm32
, and androidNativeX86
. Note that Kotlin/Native Android code can't use the normal Android SDK and is actually built with Android NDK. –
Bellybutton © 2022 - 2024 — McMap. All rights reserved.