GraalVM is a High Performance JVM which supports polyglot programming languages

Author: Shazin Sadakath

If you are a Java Developer and if you haven't heard about GraalVM, then it is about time you hear the news. GraalVM is a specialized Java Virtual Machine developed and released by Oracle. It has both an Open Source community version and an Enterprise version for serious customers.

What's so special about this, just another VM one may think. Well think again, GraalVM is not just another JVM but a unique, one of a kind JVM which supports polyglot programming, native image building, embeddable code and many more. Let's run through these features one by one;

Polyglot Programming

Imagine a world where you can run your R, C, Python, Node.js, Ruby application in one single Java virtual machine process seamlessly. That world will be GraalVM. This VM supports multiple programming languages out of the box and developers can write code support more languages. To achieve this feat, GraalVM uses JEP 243: Java-Level JVM Compiler Interface which enables a compiler written in Java to be used by the JVM as a dynamic compiler. was introduced with Java version 9. 

All programming languages except Java and Scala talks to Truffle language framework thus same profiling and debugging tools can be used for all applications. This enables Data Scientists write code in R or Python and Software Engineers to write code in Java or Node.js


The intermixing of R code inside of Java or Python code inside of Java is possible with GraalVM. The following code shows a perfect example;

import org.graalvm.polyglot.*;
import org.graalvm.polyglot.proxy.*;

public class HelloPolyglot {
    public static void main(String[] args) {
        System.out.println("Hello Java!");
        try (Context context = Context.create()) {
            context.eval("js", "print('Hello JavaScript!');");

Also following code is also possible from Javascript 

var Math = Java.type("java.lang.Math");
console.log(Math.pow(2, 16));

And both code can be run inside the GraalVM with tools provided by the distribution.

Native Images

Ever wondered the possibility of writing a Java application and then running it on a platform as a Native application. Well think no further, GraalVM provides a tool called native-image which enables to convert a standard Java application into a Operating System, Processor Architecture optimized binary with Ahead of Time (AOT) compilation. This will enable faster boot up time lower memory foot prints than that of the same application running inside the JVM. 


GraalVM is relatively new to the scene but looks very promising. The features are something developers wanted for a long time and as time progresses so will the features. So in the future we can seem more and more robust features and supported languages in GraalVM. You can learn more about GraalVM from the official site.

Tags: GraalVM Java Node Python Ruby R
Views: 1416
Register for more exciting articles


Please login or register to post a comment.

There are currently no comments.