Oracle Labs GraalVM: Polyglot

The Polyglot engine of the GraalVM allows the execution and interoperability of language interpreters for additional programming languages. This release of the GraalVM contains language interpreters for five well-known languages (JavaScript, Python, Ruby, R, and LLVM), and a teaching language (SimpleLanguage).

JavaScript: Graal.js

Graal.js is an ECMAScript version 2017 compliant JavaScript engine. It is based on the Polyglot engine and uses Graal as compiler, guaranteeing high performance and language interoperability with other Truffle-based language engines.

What are the key benefits of Graal.js?

  • Peak Performance: JavaScript applications executed with Graal.js and compiled with Graal reach a peak performance competitive to the leading JavaScript engines.
  • Server-Side JavaScript: Graal.js includes the ability to run server-side Node.js applications. It provides support for a wide range of Node.js applications, including npm modules implemented in native C/C++.
  • Language Interoperability: Providing interoperability to other Polyglot languages and to Java without sacrificing performance is another goal of Graal.js.

How can I execute JavaScript applications with Graal.js?

This release provides an execution system for JavaScript applications. You can execute ECMAScript 6 compliant JavaScript programs on the command-line shell using the js command included in the release:

# js mySourceFile.js

Take care to actually use the js command of this release, e.g. by adding the bin directory to the path:

# export PATH=/path/to/GraalVM/bin:$PATH

How can I execute Node.js applications with Graal.js?

You can also use the node executable to execute Node.js applications. Several example applications can be found in the example/node directory of the release:

# node myNodeApplication.js

For more details, see the README file in the release.

Python: Graal.Python

Graal.Python is a Python 3 implementation in the early stages of development. As such, it is not ready for any serious applications beyond simple use cases and scripting.

What will be the key benefits of Graal.Python?

  • Database integration: A primary goal of Graal.Python is to integrate with the Multi-lingual Engine (MLE) to open the ecosystem of Python packages, especially those in the data analysis realm, to be used in the database in safe and efficient manner.
  • Performance: Graal.Pytohn uses the Graal compiler to provide good performance, and we are working towards our goal of running the SciPy suite of packages both safely and fast.
  • Language Interoperability: Through the Polyglot engine, Graal.Python can interoperate with other Polyglot languages and Java without loosing performance at the language boundary.

How can I try Graal.Python

Although the python interpreter is in the early stages, simple scripts already run.

# python my_source_file.py

Ruby: TruffleRuby

TruffleRuby is high performance implementation of the Ruby programming language, compatible with MRI 2.3.

TruffleRuby is progressing fast but is currently probably not ready for you to try running your full Ruby application on. Support for critical C extensions such as OpenSSL and Nokogiri is missing. TruffleRuby is ready for experimentation and curious end-users to try on their gems and smaller applications.

What are the key benefits of TruffleRuby?

  • Peak Performance: Using the Graal compiler, TruffleRuby achieves performance on benchmarks and real application code that is well beyond anything possible with current implementations of Ruby.

  • Fast Metaprogramming: TruffleRuby is designed to optimise Ruby as it is actually used - metaprogramming included. Operations like dynamic sends, dynamically defined methods, bindings and eval are all fast.

How can I execute Ruby applications with TruffleRuby?

# ruby my_source_file.rb   

How can I use RubyGems or Bundler?

TruffleRuby currently cannot run gem install out of the box because of incomplete support for OpenSSL and Nokogiri. However there is a workaround which can be used to get both gem install and bundler install working. 

ruby -r bundler-workarounds -S gem install bundler

ruby -r bundler-workarounds -S bundle install
ruby -r bundler-workarounds -S bundle update

`bundle exec` does not need the `bundler-workarounds` module loaded. 

ruby -S bundle exec bin/rails server

FastR

FastR is an Graal based implementation of the R language. It uses the latest Graal technology to achieve high performance but also tries to not compromise on compatibility with GNUR.


What are the key benefits of FastR?

  • Peak Performance: R applications executed with FastR and compiled with Graal outperform existing R execution engines.
  • Compatiblity: R aims to be fully compatible with GNUR. Existing applications developed with the R reference implementations should run without changes.
  • Language Interoperability: Providing interoperability to other Graal-based languages like Java, Ruby or JavaScript without sacrificing performance.

How can I run R applications with FastR?

The R language shell can be started with:

# ./bin/R

R scripts can be run with the following command:

# ./bin/RScript mySourceFile.js

How complete is FastR?

FastR is still in an experimental stage. Please expect rough edges and non-working language features: