whichjdk / whichjdk.com

Which Version of JDK Should I Use?
https://whichjdk.com
127 stars 13 forks source link

Add GraalVM as an JDK option #6

Open Thihup opened 2 years ago

jochenchrist commented 2 years ago

Great idea. I will add this option. However, I have not query much experience with GraalVM in production to give a valid recommendation. Please state your opinions here, so I can summarise a validated recommendation.

JellyBrick commented 2 years ago

GraalVM *

GraalVM Native-images

GraalVM CE

GraalVM EE

danthe1st commented 6 months ago

I want to note that PGO on native-image is not available in GraalVM CE.

Mukul1127 commented 1 week ago

I would like to update here as it's been a while:

New Oracle GraalVM

GraalVM CE

GraalVM Native Images

danthe1st commented 1 week ago

Supersedes GraalVM EE

I want to note that this was more a renaming/relicensing change and GraalVM EE isn't really available any more in versions newer than the switch from GraalVM EE to Oracle GraalVM. IIRC correctly, Oracle GraalVM is free as long as you are using the most recent version or a recent enough LTS version. While Oracle GraalVM has a less strict license than GraalVM EE before (and is free when using the right/sufficiently recent versions), it is still a commercial version.

But don't trust me on Oracle's licensing :)

Less compatibility issues i think (Reflection is no longer mentioned anywhere)

It still has the same restrictions as before.

Note that native-image is a tool available for both GraalVM CE and Oracle GraalVM which compiles Java applications to native executables. It still has restrictions on Reflection, JNI, proxy classes and resources as all of these have to be declared during compilation (there are things like the reachability repository and the tracing agent making this easier). Everything not being declared there (unless native-image is able to figure it out in some way) will be eliminated as native-image makes a closed-world assumption (it eliminates all the code it detects as unused). See also https://www.graalvm.org/latest/reference-manual/native-image/metadata/ As far as I know, native-image can also do more optimizations and also has some more features with Oracle GraalVM (e.g. I think PGO and generating SBOMs with native-image is only available with Oracle GraalVM)

Supports both G1GC and ZGC (No Shenandoah still)

While that is true, I am unsure about support for Generational ZGC (in non-native-image mode).


Aside from this, native-image has some other limitations like you cannot do runtime class loading and similar things. The Garbage collectors available with native-image are:

The limitations and closed-world assumptions of native-image may or may not be acceptable depending on the exact use-case.

If anyone wants to use native-image , they probably want to use GraalVM as that tool is part of GraalVM (I think was also some other alternative but that might be mainly for some special cases IIRC).

Another thing about GraalVM (in non-native-image mode) is that it uses a different JIT (the Graal JIT) which (especially with Oracle GraalVM) can result in better peak performance.

GraalVM also supports polyglot functionality which allows combining multiple languages (e.g. it can run things like JS, Python, WASM, LLVM etc. and these can also be mixed).

That being said, GraalVM (both CE and Oracle GraalVM) have some unique features which may be worth mentioning.