Nashorn is a JavaScript runtime based on the InvokeDynamic instruction and series of APIs added to the Java VM in Java 7. These APIs are set to be radically improved in Java 8, compiling the existing JVM instruction to bytecode which will pass through the full HotSpot compiler.
If you're interested in InvokeDynamic, perhaps you'll check out the slides on a talk I gave about it:
Rhino has pretty good performance. It's about 1.6x Java's performance which made it pretty darn fast for most scripting languages built on the JVM. I would expect this new project will follow the ScriptEngine API so you could swap out a Rhino interpreter with Nasborn engine. This would make it easy to compare how much the InvokeDynamic instruction can contribute to performance boost. I wonder if it can achieve near Java performance parity.
Setting aside what 1.6x means, Rhino is much much slower than V8 or Java. In fact, there's a bit of an elephant in the room here because people don't really care about Nashorn vs. Rhino; they care about Nashorn vs. V8.
My sudoku solver http://dancing-links.herokuapp.com/ in javascript takes roughly a tenth of the time to solve a particular puzzle when running in node/V8 than in Rhino.
There is a big difference between interpreted rhino vs. compile rhino. The Rhino wikipedia page claims compiling to byte code "... produced the best performance, often beating the C implementation of JavaScript run with just-in-time". However, the benchmarks I've seen put Rhino compiled to byte code at about 60% slower than comparable Java code.
What does it mean to be about 1.6x Java's performance? Can you be specific - it doesn't seem to mean much since its implemented on the JVM. Also, I've been using it recently and "dog slow" is how I would describe it.
Roughly performance tests have shown: Java Performance (ms) * 1.6 = Compiled Rhino Performance (ms). So Rhino is about 60% slower than comparable Java code if you compile it to byte code on average.
It means algorithms runs 1.6x faster within Rhino. A JVM implemented in Rhino that runs Rhino within the JS-JVM will run even faster - roughly 2.56x faster.
Fun fact: Nashorn is the German word for a Rhinoceros and the literal translation would be "Nosehorn".
And according to Wikipedia: The word rhinoceros is derived through Latin from the Ancient Greek: ῥῑνόκερως, which is composed of ῥῑνο- (rhino-, "nose") and κέρας (keras, "horn").
Does anyone know if this project would obviate Rhino? I'd always sort of assumed that its maintenance was a bit of a low priority for Mozilla, but after seeing the bits of praise in this thread for Rhino perhaps it's not as neglected as I'd suspected.
Nashorn will not be fully backward compatible with Rhino. Nashorn will be very ECMA compliant, but will not implement some Mozilla and/or Rhino-specific extensions. So not all Rhino-based projects will be able to easily migrate. But it's not hard to imagine that Nashorn will divert attention and resources away from Rhino.
I should add that a modified version of Rhino has been bundled with the JVM since Java 6 (aka 1.6), but it is likely (if not already announced) that future releases of Java from Oracle will bundle Nashorn instead.
For others who are interested in fast JS in Java, we've been working on a embedding V8 into clojure using JNA. A working prototype that's good enough for us is at https://github.com/circleci/clj-v8.
I'm using it to port dieter (clojure asset pipeline we to serve https://circleci.com [https://github.com/edgecase/dieter ]) from Rhino to Dieter. Our current 100s asset compiles are unbearable, and are only about 4s with V8.
By "native" they mean JVM-native (not OS-native). I believe what they really mean is that they use JVM primitives for dispatch, as opposed to building their own using functor objects and reflection-like API (which was the only way to implement MOP pre-InvokeDynamic).
It is a bit misleading as there is still a lot that would have to be be emulated - the JVM does not support open types and the Java is centered around classes, which makes prototype mutation hard to implement efficiently ( InvokeDynamic somewhat helps, but would still impose a performance penalty when the prototype is changed).
I was a bit surprised to see the title here, because the Nashorn project isn't new - what's new is that it is now an OpenJDK project. Oracle has been working on it for a while, it was first announced in July 2011.
Had a try and it seems promising. The only drawback I see is that there are still bugs, and the owner is the sole developer for the project, and he seem to have plenty of other projects going on...
To have real good traction it must be easy to develop the nodejs standard library on it. If this happens, well, it would be pretty awesome. How are they going to manage the async structure for calls to other JVM compatible languages?
From the post: "This project intends to enable Java developers to embed JavaScript in Java applications and to develop free standing JavaScript applications using the jrunscript command line tool."
If you're interested in InvokeDynamic, perhaps you'll check out the slides on a talk I gave about it:
https://speakerdeck.com/tarcieri/invokedynamic-your-guide-to...