https://kotlinlang.org logo
k

Karlo Lozovina

01/21/2021, 1:47 PM
does Kotlin Native overlap in some way with what Graal Native Image is trying to do? (compete newb here, just trying to get the lay of the land)
c

Casey Brooks

01/21/2021, 3:46 PM
Not really. Kotlin/Native was really started to be able to use Kotlin on iOS, but it’s implemented using LLVM which allows for multiple “native” targets (any target LLVM supports). It creates an entirely new runtime environment which is unique to Kotlin, but the goal of Kotlin Native is just to be able to run Kotlin anywhere. I haven’t used Graal myself, but from what I’ve seen it seems to be geared more towards seamless language interop, and ahead-of-time compilation of Java apps (for better performance and smaller overall footprint, since you don’t need a full JDK installed on the local machine to run the binary). So while the output of both Kotlin Native and Graal Native are the same (native binaries), the goals of both are very different.
👍 1
j

jw

01/21/2021, 3:46 PM
Not at all. Graal native image consumes an existing IR of Java bytecode (which can be produced from Java, Kotlin/JVM, Scala, whatever) and produces a native executable. Kotlin/Native is a language that targets native directly, similar to Rust or Go.
💯 3
👆 3
n

napperley

01/22/2021, 1:24 AM
Kotlin Native with its first version (0.1) supported multiple targets, including linuxX64 and linuxArm32Hfp. Right from the start one can develop a native Linux application that runs on a Linux ARM based SBC (Raspberry Pi, Beagle Bone Black etc) for example. Kotlin Native has never been only about iOS development. Other types of development are supported by Kotlin Native, especially Linux/Embedded Linux development, which is a very big Kotlin Native area nowadays with a significant user base.
t

Tijl

01/22/2021, 10:59 AM
Worth noting that Graal can also consume LLVM bitcode, and has an LLVM backend, so while the two are separate efforts they do overlap in what they try to do (e.g. target iOS) and can actually interact (like calling Kotlin/Native from Graal, but also Kotlin/Native should be able to run on Graal for example). Of course Kotlin/Native comes with a lot less baggage, but if you view it as part of the larger Kotlin ecosystem (it’s own IR, expanded standard library, etc) the two start looking more similar.
k

Karlo Lozovina

01/22/2021, 2:20 PM
Thanks everyone for helping, it's clearer now! One more thing, Kotlin/Native will always be Kotlin-only, so no ability to bring along Java libraries?
t

Tijl

01/22/2021, 4:11 PM
Nothing is impossible, but there is 0 plan or effort ongoing for it. It would not make sense to port the entire Java runtime / standard library (including all its cruft and legacy) to Kotlin infrastructure IMHO. It makes even less sense given that Graal exists.
c

Casey Brooks

01/22/2021, 4:14 PM
Yeah, supporting JVM libraries in native is pretty antithetical to Kotlin’s entire philosophy for multiplatform development
1
💯 2
5 Views