
GraalVM - gjvc
https://www.graalvm.org/
======
kasperni
GraalVM consists of a couple of things.

1\. A modern JIT compiler written in Java that takes bytecode and transforms
it into machine code. There is a plan that it might someday replace HotSpot
[1]. However, we are probably a couple of years away from this.

2\. A native image compiler [2] that uses ahead-of-time compilation technology
to produce executable binaries of class files. This means startup times and
memory usage similar to a language such as go.

3\. An abstract syntax tree interpreter called Truffle. Which allows you to
easily implement languages on top of GraalVM. With the performance of compiled
languages but using an interpreter. You can read more about this here [3].

There are also other features such as a LLVM bitcode engine called Sulong. And
various PolyGlot functionality to support integration of whatever language you
want. [4]

[1] [https://jaxenter.com/openjdk-project-
metropolis-137318.html](https://jaxenter.com/openjdk-project-
metropolis-137318.html)

[2] [https://www.graalvm.org/docs/reference-manual/native-
image/](https://www.graalvm.org/docs/reference-manual/native-image/)

[3] [https://www.beyondjava.net/truffle-compiler-
compiler](https://www.beyondjava.net/truffle-compiler-compiler)

[4]
[https://github.com/oracle/graal/blob/master/sulong/README.md](https://github.com/oracle/graal/blob/master/sulong/README.md)

~~~
nathell
[3] is made possible thanks to a variation of the idea called "Futamura
projections":

[https://en.wikipedia.org/wiki/Partial_evaluation#Futamura_pr...](https://en.wikipedia.org/wiki/Partial_evaluation#Futamura_projections)

~~~
rubyfan
I read that as Futurama and when I clicked through was expecting to see a
picture of Fry or Hypnotoad as some time travel concept as inspiration. Even
better, when I clicked through I read it the first time and thought “wow cool
someone’s last name is Futurama” then I read it again haha.

~~~
smoll
because you wrote Futurama and referred to it so many times in this reply,
when I skimmed the thread I read the word in this post and the one above it as
Futurama. it took me like 3 re-reads to realize the original did NOT say
Futurama.

------
Borkdude
Check out babashka, a Clojure interpreter with instant startup, running in a
GraalVM-compiled binary:

[https://github.com/borkdude/babashka](https://github.com/borkdude/babashka)

~~~
slgeorge
This is a good example of where Graalvm's native image is interesting. This is
a CLI tool that lets Clojure developers create scripts that are as fast as
bash scripts. Clojure may well not be your bag, but stay with me - we're
talking about CLI or TUI's written in Java (or a java-based language) that are
easy to distribute as statically compiled binaries.

------
dang
There have been many threads
([https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...](https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=GraalVM%20comments%3E1&sort=byDate&type=story&storyText=none))
including:

2019
[https://news.ycombinator.com/item?id=20987946](https://news.ycombinator.com/item?id=20987946)

2019
[https://news.ycombinator.com/item?id=19885922](https://news.ycombinator.com/item?id=19885922)

2018
[https://news.ycombinator.com/item?id=16859559](https://news.ycombinator.com/item?id=16859559)

2018
[https://news.ycombinator.com/item?id=16995967](https://news.ycombinator.com/item?id=16995967)

------
Hitton
I have hard time being deeply invested in GraalVM considering that the most
interesting stuff tends to be kept proprietary (e.g. profile-guided
optimizations).

~~~
amelius
Also, if you're like me, you simply don't want to deal with the law firm
called Oracle.

~~~
mumblemumble
That's the worrying thing to me. Oracle's business model seems to be to keep
prices reasonable just as long as it takes to build up a customer base, and
then start squeezing.

I'm fascinated by GraalVM, but I'm hesitant to take even one step down a path
that leads to Oracle using my actual software implementation platform to shake
me down for money. I'd actually rather take the development effort and
performance hit on using gRPC or similar to get my Java and Ruby modules
talking to each other than to get locked into a potentially weaponized version
of the Java platform.

~~~
qorrect
> weaponized version of the Java platform

That was really sad to read. Oracle is really hurting the java language and
ecosystem.

~~~
mumblemumble
Realistically, this isn't super new. After what happened to Dalvik 10 years
back, and later to Adopt, one could argue that the Java Community Process
itself, and therefore the very soul of Java, has been weaponized.

------
ridiculous_fish
Can someone please give a sober explanation of what GraalVM, is and how
Truffle works?

I think it is somewhat analogous to LLVM: Graal exposes a "language agnostic"
API which allows multiple front-ends. There's a front-end for Ruby, JS, C++,
others. But this API is higher level than LLVM: it knows about objects, and
allows tricks like querying properties across language boundaries.

But I can't imagine what this API looks like! For example, graaljs exists: how
do JS semantics get expressed in a Java VM? What does a getProperty
instruction look like? How does it know when to invalidate inline caches?

~~~
sanxiyn
Here is Truffle's Javadoc: [https://www.graalvm.org/truffle/javadoc/overview-
summary.htm...](https://www.graalvm.org/truffle/javadoc/overview-summary.html)

See especially Assumption, CallTarget, and DynamicObject.

------
greatjack613
As an engineer who lives and breathes java, both in the context of high
performance servers and android apps, can someone explain what this does for
me besides for quick startup times through the native image feature? what are
the benefits of this?

~~~
de6u99er
You can compile your Java code into an executable which doesn't require Java
to be present. Advantages would be reduced memory footprint and quicker
startup times, which could be ideal for microservices started on demand
instead of constantly running.

That being said, the people at Spring don't recommend it for production use
yet. Here's what they have to say about it:

"While GraalVM is now GA, GraalVM native image feature which allows ahead-of-
time compilation of Java applications into executable images is only available
as an early adopter plugin, so we don't consider it production ready yet."

[https://github.com/spring-projects/spring-
framework/wiki/Gra...](https://github.com/spring-projects/spring-
framework/wiki/GraalVM-native-image-support)

~~~
bmc7505
> You can compile your Java code into an executable which doesn't require Java
> to be present.

Wasn't this feature already supported in JDK 14 with the jpackage tool?

[https://openjdk.java.net/jeps/343](https://openjdk.java.net/jeps/343)

~~~
vbsteven
If I understand correctly, the difference between jpackage and GraalVM is
this:

Jpackage bundles a small Java VM (with only the features you use) together
with your compiled bytecode into a single executable. When it runs it starts
up the VM and executes bytecode on that VM exactly the same as it would be if
you were to run a jar on a preexisting JDK/JRE installation.

Graal compiles your full app ahead of time into a native code binary. There is
no bytecode/translation happening at runtime. That is why GraalVM advertises
faster startup and lower memory footprint.

So there are essentially 3 ways to run JVM (Java/Scala/Kotlin/...) code:

* compile into bytecode jar -> requires existing VM runtime

* compile into bytecode jar + bundle VM runtime -> no dependencies required, runs as the previous option

* compile into native binary -> no dependencies required, runs native, starts and runs faster

~~~
vips7L
> Jpackage bundles a small Java VM (with only the features you use) together
> with your compiled bytecode into a single executable. When it runs it starts
> up the VM and executes bytecode on that VM exactly the same as it would be
> if you were to run a jar on a preexisting JDK/JRE installation.

This is incorrect. Jpackage creates an installer which will unpack the VM
image and any other resources.

I've tried it with a small CLI tool and it actually doesn't work that well (at
least on Windows).

------
nwmcsween
Does graalvm work with openjdk or any java VM alternative? And does Graalvm
have the weird Oracle no business use license that Oracle Java has?

~~~
ksec
You can use Redhat distribution of GraalVM.

[https://github.com/graalvm/mandrel](https://github.com/graalvm/mandrel)

------
andretti1977
I'm happy with language interoperability as a concept but how can i mix java
and js in the same codebase with graalvm? And would it make sense? What are
the advantages of this approach?

~~~
fniephaus
Currently, you'd use the polyglot package that ships with the GraalVM SDK:

[https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Con...](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Context.html)

Here are a couple of demos:

[https://github.com/graalvm/graalvm-demos](https://github.com/graalvm/graalvm-
demos)

I said "currently", because you currently have to use the host Java, that is
the Java on top of which all other languages are implemented. The GraalVM team
is working on Project Espresso, a Java written in Truffle. That will make
polyglot programming with Java much more consistent with the rest of the
languages. Project Espresso isn't public yet, but here's the latest update
from the team working on it:

[https://github.com/oracle/graal/issues/1656#issuecomment-664...](https://github.com/oracle/graal/issues/1656#issuecomment-664335618)

------
crudbug
How is GraalVM different from Eclipse OMR [1] ? Seems both are doing AOT and
modular language development.

[1] [https://www.eclipse.org/omr/](https://www.eclipse.org/omr/)

------
eyelidlessness
So... the polyglot featureset is simultaneously terrifying and super
impressive.

~~~
pjmlp
While impressive, that was one of the premises for the CLR, and both build on
top of language environments from mainframes.

~~~
rbanffy
> both build on top of language environments from mainframes

They also had virtual machines and five nines before it was cool.

------
kgoutham93
Intuitively how does any Java program compile into an executable?

~~~
tutfbhuf
Instead of compiling Java to Java bytecode which is then executed by the JVM
(e.g. Hotspot), you compile it to native machine code/assembly + runtime
(Substrate VM). However you loose the cross-platform ability and Java
reflections won't work out of the box.

~~~
pas
What's the GC performance of Substrate VM's GC? Is it still the 1G young 3G
old thing?

What's the long term vision? In theory can this thing become "better" than
HotSpot, JIT and G1/Z/Shenandoah?

------
gigatexal
How “early stage” is the python support?

------
galaxyLogic
What about an IDE? Is there an IDE?

~~~
abhijat
At least for Java / Scala etc intellij works as it would normally. You just
need to point to the graalvm JDK instead of your usual JDK.

~~~
galaxyLogic
Ah I see

