JavaScript on the JVM is better and faster but not always friendlier with Nashorn, the rebuilt JavaScript interpreter

Nashorn, pronounced "nass-horn," is German for "rhinoceros," and it's one of the animal names for a German tank destroyer used in World War II. It's also the name of the replacement -- introduced with Java 8 -- for the old, slow Rhino JavaScript engine. Both Rhino and Nashorn are implementations of the JavaScript language written to run on the Java Virtual Machine.

Obligatory rant: JavaScript may have Java as part of its name, but the two languages are very different in spirit and design, as well as in their implementations. Nevertheless, one way of implementing a JavaScript interpreter is to compile JavaScript into Java byte codes, which is what Rhino and Nashorn were designed to do.

You probably think of JavaScript in terms of scripting Web browsers, and you'd be right for the most part. It's also used for servers. For example, Node.js is used to build fast, lightweight servers based on the V8 JavaScript engine from Google Chrome. JavaScript engines in Web browsers have access to the HTML document object model (DOM) and can manipulate HTML elements through the DOM. Given that different Web browsers have different DOMs and JavaScript engines, frameworks such as jQuery try to hide the implementation details from the programmer.

Nashorn, and Rhino before it, explicitly do not support the browser DOM. Implemented on the JVM, they are typically called in for end-user scripting in Java applications. Nashorn and Rhino can be embedded in Java programs and used as command-line shells. Of course, the additional magic needed when you are scripting Java from JavaScript is bridging the data and type mismatches between the two languages.

Problems with RhinoRhino development started at Netscape in 1997 for an ill-fated "Javagator" project and was released to Mozilla.org in 1998. It was then licensed to Sun and others. Honestly, 1998 might as well be the Jurassic Period, as Internet development goes -- 16 years later, Rhino has clearly shown its age. According to Jim Laskey of Oracle, the principal developer of Nashorn:

The performance of Rhino has fallen far behind that of other JavaScript engines. In order to improve performance, at this point Rhino would have to be rewritten to replace its interpreter with a code generator designed to fully utilize the JVM. Rather than undertake a major rewrite of the very old Rhino code, we have chosen instead to start from scratch.

I'm sure this is all true, but as a jaded developer and development manager I find the last sentence highly amusing. After all, major rewrites are never fun. Starting from scratch is always fun.