I am trying to grasp and explain the difference be...
# multiplatform
m
I am trying to grasp and explain the difference between platform and target. Is this correct?
Kotlin/JVM, Kotlin/JS and Kotlin/Native are three technologies used to compile Kotlin code into different platforms. For instance, Kotlin/JVM can be used to compile Kotlin code for Android or for purely JVM platform, and Kotlin/Native can be used to compile Kotlin code for iOS, watchOS or Android NDK platform. For many of those platforms, there are multiple targets, like when we compile with Kotlin/Native to iOS platform, we can Apple iOS on ARM64 or Apple iOS simulator on x86_64.
👀 2
e
Looks correct to me.
a
Yep 💯
b
Target != Platform only for kotlin native. In jvm and js context they both mean the same thing.
j
Are node.js and a browser the same platform? Is JS output and WASM output the same platform? Because all four of those use the Kotlin/JS compiler.
So no, I would not say this distinction only applies to native.
b
I wish, unfortunately no at the moment. Those are more like android flavours
It's a mess
j
You could just as easily say native only targets LLVM IR the same way Kotlin/JVM only targets Java bytecode. That means native only has one platform: LLVM
b
There's a youtrack asking to separate them into targets
o
While platform in general refers to a type of runtime infrastructure, the term is used with different granularity. As noted above, people might just talk about the JS platform, or differentiate between browser and Node.js (and then differentiate further between JS/browser and Wasm/browser). A target is bound to a platform, but is basically a user-defined artifact. Often targets represent platform variants, but they don't have to be constrained to that. If you want to split your JVM backend into several services, you could have several targets for the exact same platform, e.g. "backendCache", "backendMessaging", ...