This page describes a simple example of a polyglot application you can run with GraalVM.
Download or clone the repository and navigate into the
Build the benchmark. You can manually execute
npm install, but there’s also a
build.sh script included for your convenience.
Export the GraalVM home directory as the
$GRAALVM_HOME and add
to the path, using a command-line shell for Linux:
and for Mac OS:
Note that your paths are likely to be different depending on the download location.
Note that this application contains R code, so you need to install the R language component to add R support to GraalVM, run the Graal updater command to do it:
gu install org.graalvm.r
For more information on using Graal updater please refer to its documentation.
Running the application
To run the application, you need to execute the
You can run it with the following command (or run the
$GRAALVM_HOME/bin/node --jvm --polyglot server.js
If you would like to run the benchmark on a different instance of Node,
you can run it with whatever
node you have. However, presumably, the polyglot
capability will not be supported.
Debugging polyglot applications
GraalVM also supports debugging of polyglot applications and provides a built-in
implementation of the Chrome DevTools Protocol. Add the
--inspect parameter to the command line, open the URL the application
prints at the startup in the Chrome browser and start debugging, set breakpoints,
A note about the application
This sample application for brevity contains large-ish snippets of code inside the strings. This is not the best approach for structuring polyglot apps, but it is the easiest to show in a single file.