Skip to content

Instantly share code, notes, and snippets.

@frank-dspeed
Created August 11, 2020 09:28
Show Gist options
  • Save frank-dspeed/67a4d8b3d0c11c1358cd6f016db2d170 to your computer and use it in GitHub Desktop.
Save frank-dspeed/67a4d8b3d0c11c1358cd6f016db2d170 to your computer and use it in GitHub Desktop.
Tutorial How to Run NodeJS Code With Java InterOp

Many People do not fully understand on the first read what is what as the names are similar so we make it now clear

GraalJS Node

is a NodeJS Fork that Replaces V8 with GraalVM and so Also adds a Full JVM

GraalJs

is the main JavaScript Interpreter used by GraalVM to interpret GraalJS it is what is Replacing V8 inside GraalJS Node It is Implemented using the truffle Framework for GraalVM

Pros & Cons

  • https://www.graalvm.org/docs/reference-manual/compatibility/ - NodeJS & GraalJS Node Compatibility
  • GraalJS is a ECMAScript 2020 implementation
  • You can run with NodeJS InterOp via graaljs-node and then call your Java Code via graaljs-node
  • You can not run your java code via the JVM and then have node interop

Wrap your Java Applications inside GraalJS Node

So lets start to do the right thing when we plan to use a lot of JavaScript to interop with our Application it makes only sense to use graaljs-node.

When you do so and you come from NodeJS you will face issues when your using NodeJS packages like http and other stuff.

But there is good news you can get much faster Applications when you use for example vertx or a other Java HTTP Handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment