OpenJDK Proposes Project Galahad to Merge GraalVM Native Compilation
infoq.com
infoq.com
Cue the "you could always do that with some semi-supported neglected FOSS like GCJ or some niche commercial product all 3 people used" from certain HN circles -- you know who you are :)
If they also decide to merge support for other languages (including WASM and LLVM) we will be able to run everything that compiles to WASM and to LLVM on the same runtime - in the same JVM. So we will get another "Docker Without Containers"...
EDIT: It seems that I am wrong with the above 1% statement. I meant that about 1% of the Java standard library is written in C/C++. Regarding JVM: I guess that the whole HotSpot VM will be replaced with GraalVM in the future and when this happens, majority of the JVM code will be in Java.
The embedded and systems space are hard and require special talent and knowledge. You can't just take some front-end React developer and get them writing quality systems C code in a weekend... people spend entire careers in that space, and the number of people interested in that work shrinks by the year (look at all developer surveys).
I think the language difference is a red herring.
I always felt they were hostile to understanding OSes and problems/solutions they provide and thereby limiting themselves to mostly junior C devs who didn't rock the boat by making real OS features for the JVM.
That's the extreme opposite of raw C (or raw JavaScript, etc.) in which it's very easy to believe that you have solved an issue, only to realize much later that you've been entirely misunderstanding some constructions of the language and (if your code somehow managed to land) you have made the entire product unstable or insecure without realizing it.
Of course, there are tradeoffs to each approach. But I believe that investing in Rust was a great initiative from Mozilla.
I don't think C is special in this regard.
Most developers you see/hear/interact with are not C developers - rather they use higher level languages mostly to build web apps and mobile apps.
Graal doesn't affect memory management. It's a JIT compiler, not a GC. Although there's a relatively simple GC written in SystemJava for native images, G1, ZGC and Parallel will continue to be the standard GCs in the regular JVM for the foreseeable future and they are all written in C++.
If you do not count the standard library as part of the JVM (but part of the JDK), then the JVM is written mostly in C++.
The JIT is probably half of the VM and is written in C++.
Github [1] says (for the whole JDK, not just the VM): Java 75.1% C++ 13.4% C 7.4% Assembly 2.3% Objective-C 0.4%
I work at a company with one large C++ codebase, and also many Go projects where C and C++ knowledge are helpful. We have trouble hiring good C++ developers, because our candidate pool starts as "people who want to write web applications".
But if you're already restricted to people who want to work on an extremely mature compiler, VM, and JIT - is lack of C knowledge really what's making it hard to hire people? These are people who are likely to end up reading kernel code and C-defined ABI documentation and etc. etc. even if the codebase is 100% Java...
Also there is a large chunk of people (like me) who don't care about Java (the language) but very much about the JVM (and to some degree also about the Java ecosystem). I'm a Scala developer. But I'm also interested lately in Rust (and to some degree C++, as both languages are related), 'cause, you know, max performance and full control, and such.
So at least when it comes to interests there is some pool of people for sure who would like to look into the low-level JVM internals.
You have trouble hiring good C++ developers, because you don’t pay enough.
How much is a good salary for that if you're remote (but US based) and have about 10 years of decent experience (plus a PhD in CS).
Parent is just talking out of his/her ass.
I believe this is still incorrect. GraalVM is HotSpot with the Graal JIT compiler and the truffle languages.
Cue the "you could always do that with some niche commercial product all 3 people used" from certain HN circles -- you know you who are :)
For anyone else, the normal JVM is likely a better choice for now - the tech built in there is very mature and battle tested.
With that said - baking a bunch of GraalVM features into the normal JVM is nothing but good for everyone. Native AOT compilation does have it's uses outside microservices/serverless, and some cross-pollination of VM ideas is a great idea.
So you can get all the operational benefits of the JVM + a nice set of languages to play with along with interopt cross language (python calling java calling ruby calling perl, etc).
Here's the languages they already have.
https://github.com/oracle/graal/blob/master/truffle/docs/Lan...
From what I can tell, the effort to get any particular language running on Graal is non-trivial, leading to that relatively small list of supported languages - most of which seem to be custom dialects in one fashion or another. Perhaps I'm wrong though...
Many of the languages people use in the real world are really large, really old, really hairy and rely heavily on native extensions that poke arbitrary interpreter internals. Truffle at least makes these implementable with higher performance, and the team size needed to get that done isn't infeasible. But implementing a Ruby or Python will never be a five minute job regardless of what tech you use.
While LLVM or WASM support is nice, most modern languages are not compiling to either one by default, and likely means it's not "turn key" to get your system running on Graal anyway.
How long does take to implement a programming language? Well, from hours to years... depending on the language. To make my point; how long would it take to implement a JVM? A JVM is a complex beast, so I would myself guess from years to a decade probably, what if I told you, that Espresso was written in just 6 months by an intern and a seasoned engineer... in just 6 months it was able to Minecraft and even run itself. I assure you there's no magic here, and certainly no blinding talent either; the only reason for this unheard productivity was Graal/Truffle. So, whenever I talk about Espresso I always give all credit to Graal/Truffle, it is a sublime platform for implementing fast languages and runtimes, of which Espresso is just a byproduct.
Just a tiny side note, a basic toy JVM is actually not that hard (without JIT, trivial GC, limited standard lib) from personal experience, of course a performant/having feature parity one is indeed impressive (though I yet to play with Espresso!)
The smallish list of languages is just due to lack of effort, plus lack of immediate benefits — it is not hard to create an alternative language implementation. It is very hard to create one that is 100% drop-in replaceable with the real thing as every sufficiently complex program will depend on implementation quirks as well.
I am still impressed that it can beat V8 handily without extensive further optimization work in the JVM, but it's not that surprising.
For those you may be better with IBM OpenJ9:
https://www.eclipse.org/openj9/
It also integrates with CRIU so you can almost instantly start/stop the JVM:
https://blog.openj9.org/2022/09/26/getting-started-with-open...
As best I can tell, these are the docker images: https://hub.docker.com/_/ibm-semeru-runtimes
$ docker run --rm ibm-semeru-runtimes:open-11-jdk java -version
openjdk version "11.0.17" 2022-10-18
IBM Semeru Runtime Open Edition 11.0.17.0 (build 11.0.17+8)
Eclipse OpenJ9 VM 11.0.17.0 (build openj9-0.35.0, JRE 11 Linux amd64-64-Bit Compressed References 20221031_559 (JIT enabled, AOT enabled)
OpenJ9 - e04a7f6c1
OMR - 85a21674f
JCL - a94c231303 based on jdk-11.0.17+8)"GraalVM" is the umbrella name of all these things packaged together, together with a couple languages implemented in Truffle. That's what you download when you go to the website.
Galahad is a proposal to merge the Graal code generator library in Java, into OpenJDK's codebase, so that it is developed in tandem and comes with first-class support. And none of the other things, for now (Native Image will come later.) But you can also do this today: you can instead configure a stable LTS release of Java to use Graal as the code generator for the HotSpot VM, as an alternative to C2. It's a little bit of work to do so, but you can use any compliant OpenJDK build and test it out. Galahad will just make this an "out of the box" option rather than having to get Graal from Maven or whatever.
So, you can just test things incrementally and see if Graal gives performance improvements over C2. You don't need to throw out your whole existing JVM, it's mostly just a new maven dependency. That's a much simpler and more targeted change, if you haven't given it a try (mostly by fiddling with some JVM -XX flags, as usual.)
From GraalVM docs [1] on memory management: "The G1 GC (only available with GraalVM Enterprise Edition) is a multi-threaded GC that is optimized to reduce stop-the-world pauses and therefore improve latency, while achieving high throughput. Currently, G1 can only be used in native images that are built on Linux for AMD64."
[1] https://www.graalvm.org/22.2/reference-manual/native-image/o...
That being said, most of the JVM projects I'm very familiar are written in Clojure, so they may well be outliers compared to Java or other JVM languages.
To my knowledge, cross-compiling "native" Linux and Windows binaries using Java requires duct tape, chewing gum, and warp-packer.[1][2] If there's another way to cross-compile a Java application into a standalone binary for multiple target platforms, do tell!
GraalVM isn't a panacea. For example, GraalVM cannot compile Renjin[3], a pure Java R interpreter, which means switching from Renjin to FastR. Not trivial. Other sinkholes likely lurk that'll only reveal themselves when walking through the weeds.
[0]: https://github.com/DaveJarvis/keenwrite
[1]: https://dave.autonoma.ca/blog/2020/06/29/write-once-build-an...
As far as I can tell Graal does not have cross-compilation ability currently (there is an open issue here: https://github.com/oracle/graal/issues/407)