News for hackers. Stuff that matters.
Re:Kotlin vs. Java by svnpenn on Monday December 16, 2019 @05:47PM (#21808309)
I learned that Kotlin has a native compiler:

https://github.com/JetBrains/kotlin-native

does this mean end user can run without JRE? Does Java proper have something similar?

Re:Kotlin vs. Java by ajross on Monday December 16, 2019 @06:08PM (#21808549)
Java had a native gcc front end way back in the 90's. No one used it and they eventually dropped it. This isn't really a killer feature for the problem areas targetted by Java developers.

Android ART is, effectively, a native compiler for a Java-targetted (but not JVM) bytecode too.

Re:Kotlin vs. Java by vips7L on Monday December 16, 2019 @07:24PM (#21809200)
I think one of the main use cases of graal native will be for container's with smaller memory footprint (where GO traditionally shines) or where startup time needs to be fast.
Re:Kotlin vs. Java by jillesvangurp on Tuesday December 17, 2019 @02:59AM (#21811590)
This is correct. It's a proper compiler (on top of llvm) and when you use it, you can't use Java classes or libraries. Instead, Kotlin has a notion of multi platform libraries with e.g. serialization, http, and IO libraries that you use. Short term this is aimed at mobile developers looking to build libraries that compile to IOS and Android. Long term this will likely pop up in other places as well.

There's also a javascript transpiler and tools to adapt typescript definitions so you can use Kotlin for react work or node.js work as well.

Re:Kotlin vs. Java by soulnothing on Tuesday December 17, 2019 @12:27AM (#21810908)
It's alpha/beta there is a lot of talk about concurrency and memory management.

But yes this goes down to llvm. You can also import and compile c/c++ libraries via headers. I've been doing it recently.

This is the strength with multi platform declarations. you can write a back-end service then pick the best run time for that component.

https://kotlinlang.org/docs/reference/native/c_interop.html

Re:Kotlin vs. Java by spelunker on Monday December 16, 2019 @05:55PM (#21808415)
GraalVM can build native images: https://www.graalvm.org/docs/reference-manual/native-image/

I haven't heard of kotlin-native, but apparently it isn't using GraalVM under the sheets which is interesting.

Re:Kotlin vs. Java by thu2111 on Tuesday December 17, 2019 @07:19AM (#21812750)
Kotlin Native predates the release of native-image. Also it's actually a slightly different language. Kotlin/Native really wants you to not write shared memory multi-threading. All variables are thread local by default. It has special constructs for interop with C libraries, and uses a sort of reference counting Python-esque memory manager if I recall correctly. You can only use C or other Kotlin/Native libraries.

GraalVM native images are a different matter. It uses the Java memory model and ahead of time compiles all the code to native. The "VM" part is bundled with the binary but it's very small and thin. Really it's just a simple generational GC and a bit of support for reflection over things you said you want to reflect over.

Both produce small binaries that start as fast as C programs do. In fact the GraalVM team have advertised cases where native-image binaries start faster than C programs do.

Re:Kotlin vs. Java by saagarjha on Monday December 16, 2019 @05:57PM (#21808426)
Is this like Graal (e.g. build the VM into the “native” image) or actually compiling to a just a native binary?
Re:Kotlin vs. Java by AndrewBissell on Monday December 16, 2019 @07:02PM (#21808998)
Yes and no. It's "like Graal" in that there is a Kotlin/Native runtime which is built into the binary. It's "not like Graal" in that it is not building in the entire JVM, and K/N code provides things like manual memory management APIs which are not available in e.g. a Java->Graal context.
Re:Kotlin vs. Java by vips7L on Monday December 16, 2019 @05:51PM (#21808367)
GraalVM has a native-image compiler.

https://www.graalvm.org/