Skip to content

Commit

Permalink
Update FunctionGraph Demo README
Browse files Browse the repository at this point in the history
  • Loading branch information
olyagpl committed Dec 11, 2023
1 parent 9311186 commit f4054c6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions functionGraphDemo/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# FunctionGraph Demo - Polyglot JavaScript, Java, R application
# FunctionGraph Demo - Polyglot JavaScript, Java, R Application

This repository contains the code for a demo application for [GraalVM](graalvm.org).
This is a multi-language application mixing JavaScript, Java, and R to demonstrate GraalVM polyglot capabilities.

> This demo requires GraalVM R runtime version 22.3.1 or lower.
### Prerequisites

- GraalVM
- [Node.js support](https://www.graalvm.org/latest/reference-manual/js/NodeJS/)
- [Ruby support](https://www.graalvm.org/latest/reference-manual/ruby/)
- [R support](https://www.graalvm.org/latest/eference-manual/r/)
- [GraalVM 22.3.0 or lower](https://www.graalvm.org/)
- [GraalVM Node.js runtime](https://www.graalvm.org/22.3/reference-manual/js/NodeJS/)
- [GraalVM Ruby runtime](https://www.graalvm.org/22.3/reference-manual/ruby/)
- [GraalVM R runtime](https://www.graalvm.org/22.3/reference-manual/r/)

## Preparation

1. Download and install the latest GraalVM JDK with Node.js, R, and Ruby languages support, using the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader).
1. Download and install GraalVM 22.3 with the Node.js, R, and Ruby languages support, using the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader).
```bash
bash <(curl -sL https://get.graalvm.org/jdk) -c 'nodejs,R,ruby'
bash <(curl -sL https://get.graalvm.org/jdk) graalvm-ce-java17-22.3.0 -c 'nodejs,R,ruby'
```
Follow the post-install message.

2. Download or clone GraalVM demos repository and navigate into the `functionGraphDemo` directory:
```bash
Expand All @@ -26,10 +29,10 @@ This repository contains the code for a demo application for [GraalVM](graalvm.o

3. Build the application by running `npm install`.
```bash
$JAVA_HOME/bin/npm install
$JAVA_HOME/bin/npm install
```

Now you are all set to run the polyglot JavaScript, Java, R application.
Now you are all set to run this polyglot application.

## Running the Application

Expand All @@ -39,14 +42,10 @@ To run the application, you need to execute the `server.js` file providing `--j
$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](http://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.

## Debugging Polyglot Applications

GraalVM supports [debugging polyglot applications](https://www.graalvm.org/tools/chrome-debugger/) 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.
GraalVM supports [debugging polyglot applications](https://www.graalvm.org/22.3/tools/chrome-debugger/) 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.

0 comments on commit f4054c6

Please sign in to comment.