Reputation: 2623
I am trying to understand if there is some fundamental difference between Nashorn and V8. Besides the former being used in JVM and the latter in Node/Browser, what are main differences between those JavaScript engines?
Are they interchangeable? I.e. is it possible to use Nashorn in browser and V8 in JVM?
Upvotes: 1
Views: 1141
Reputation: 40501
V8 developer here. I know almost nothing about Nashorn, so I can't give a comprehensive comparison.
According to Wikipedia, Nashorn is written in Java and hence runs on the JVM. V8 is written in C++ and compiled to native code. That's a pretty fundamental difference for practical purposes: neither Chrome nor Node.js contain a JVM, so they couldn't run Nashorn. In the other direction, V8 would certainly not be a drop-in replacement for Nashorn in the JVM, because it would require very different mechanics to bridge between the Java and JavaScript worlds. So as @Pointy says, I would not call them "interchangeable".
("Possible" is a very vague question. In software, anything is technically possible, if you're willing to write or rewrite enough code... your only limit is the number of years before retirement. If your question is whether it's "easily possible", then the answer is a resounding "no".)
Upvotes: 3