This repository contains the code for a demo application for GraalVM.
- GraalVM
- Node.js support
- Ruby support
- R support
-
Download and install the latest GraalVM JDK with Node.js, R, and Ruby languages support, using the GraalVM JDK Downloader.
bash <(curl -sL https://get.graalvm.org/jdk) -c 'nodejs,R,ruby'
-
Download or clone GraalVM demos repository and navigate into the
functionGraphDemo
directory:git clone https://github.com/graalvm/graalvm-demos
cd graalvm-demos/functionGraphDemo
-
Build the application by running
npm install
.$JAVA_HOME/bin/npm install
Now you are all set to run the polyglot JavaScript, Java, R application.
To run the application, you need to execute the server.js
file providing --jvm
and --polyglot
flags:
$JAVA_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, usually the polyglot capability will not be supported and the app will not run successfully.
Open localhost:8088 and enjoy the output.
Play with the source code, for example, type 1 * 7
in a function field and press "Draw Function".
Restart the application to see what else can you do with the mix of JavaScript, Java, and R.
GraalVM supports debugging polyglot applications too, add the --inspect
parameter to the command line, open the URL the application prints at the startup in Chrome browser.
You can debug, set breakpoints, evaluate expressions in this app in the JavaScript and R code alike.