GraalVM: THE HOLY GRAIL OF VIRTUAL MACHINES

Interlogica
4 min readAug 20, 2018

by Marco Gazzuolo

With such a pretentious name, Oracle presents what it considers to be the Holy Grail of Virtual Machines. But what are we talking about?

GraalVM is an ecosystem based on JDK 8 (Java Development Kit 8), which includes a Universal Virtual Machine with shared runtime.

Why is it so special? GraalVM runs polyglot applications mixing the strengths of different programming languages. There can be, for instance, a web application, like “Weather Predictor“, where JavaScript, Ruby, and R work together without any compromise — conflicts — and at very high performances.

Today’s supported languages are JavaScript, Python, Ruby, R, JVM-based languages such as Java, Scala, Kotlin, and LLVM-based languages such as C and C++.

As an ecosystem, GraalVM is a set of components, each with its own specific function:

Graal

A dynamic Just-In-Time (JIT) compiler which improves application efficiency and speed.

API Graal Polyglot

API combining programming languages into a shared runtime.

Graal SDK

Useful API for the integration of Graal languages and the configuration of native images.

JVM Oracle HotSpot

Runtime environment for JVM-based languages.

GraalVM FEATURES

This Oracle solution provides new perspectives on data processing contained within Oracle 12c and MySQL databases, in addition to the ability to run multilingual applications.

Using the Multilingual Engine (MLE) of the database, it is possible to execute Node.js modules written in JavaScript within the two DB queries and procedures.

GraalVM is also able to make Java applications faster with a new compilation technology Just In Time, and, no small matter, to compile the Java bytecode into machine code.

It contains a function which allows you to create native images for existing applications based on JVM. The image generation process uses static analysis to find any code which can be reachable from the main Java method, and then perform the Ahead-Of-Time (AOT) compilation.

The resulting native binary contains the entire program in the form of a machine code for its immediate execution.

These features allow you to create a Native Java Function, as described in this tutorial. Or you can link to other native programs and include the compiler in an optional way.

GraalVM can also run JavaScript applications written for Node.js, replacing V8 (Google JavaScript engine also used by Node.js). The main advantages of this operation are firstly in polyglot applications (e.g. in Java, R or Python libraries), then in running processes with large heap configurations and Java garbage collectors, and, last but not the least, in using the interoperability of GraalVM to define the data structures in C/C++, in order to share it with JavaScript. These features permit the use of existing Java libraries or Java frameworks, such as Spark, by Node.js processes. In addition, you can use R or Python, for instance, to make data science directly from a JavaScript application.

THE 3 STRANDS OF APPLICATION IN INTERLOGICA

Currently, at Interlogica, we are testing the potential of this technology in three main strands, as Twitter is already using GraalVM in the production, with excellent results, to what they claim.

  1. The first strand concerns the optimization in the usage of resources, and performance increase by existing Java applications;
  2. The second is the creation of polyglot solutions, taking maximum advantage of the strengths of each language, especially in fields like data science and machine learning, where Python is covering the lion’s share, but C/C++ still continues to have the best performances.
  3. The chance to create machine codes for its immediate execution within embedded devices and IoT (Internet of Things), where resources are smaller and it is essential that the code stays minimal, for saving memory and runtime.

GraalVM still presents some errors of youth, completely understandable since version 1.0 is still going silver.

The potential of this product still remains high, and opens new scenarios in the development of a multitude of software solutions.

Originally published at www.interlogica.it on August 20, 2018.

--

--

Interlogica

We are a company at the crossroad between tech & human evolution. Catch a glimpse of who we are by reading our insights!