Oracle: Switch now from Nashorn JavaScript engine

With plans to deprecate the Nashorn JavaScript engine in the upcoming Java Development Kit (JDK) 11, Oracle is encouraging developers to take a look at GraalVM virtual machine instead. Oracle says it’s more capable than Nashorn, and it has laid out a migration path from Nashorn to GraalVM. Oracle does plan to support Nashorn for a few years to provide time to migrate.

Like Nashorn, GraalVM supports JavaScript on the JVM. But GraalVM is independent of Java itself.

Oracle cited multiple advantages GraalVM has over Nashorn:

A more complete implementation of JavaScript standards, with support for the ECMAScript 2016 and ECMAScript 2017 editions and some support for ECMAScript 2018.
Full support for the Node.js server-side JavaScript platform, which is compatibie with almost all Node.js modules.
The ability to execute additional languages including Python, R, and Ruby.
Better performance than existing JVM-based engines and ability to use the GraalVM compiler’s advanced optimizations.
To help developers migrate from Nashorn to GraalVM, Oracle Labs has added a compatibility flag (—nashorn-compat) that removes the need for tedious rewrites to move a Nashorn application to GraalVM.

A common polyglot API in GraalVM provides interoperability with supported languages. Values can be passed from one language to another. No copying or marshalling is necessary.

GraalVM can run either in the context of the JDK 8-based GraalVM installation or the standard JDK installation starting with JDK 11, which arrives in September. Although GraalVM will not be included with the JDK, it can run on a standard JDK 11 installation by adding it to the module path. GraalVM also can be embedded as part of platforms such as OpenJDK or Node.js, as well as within a database.