Nashorn A New JVM JavaScript |
Written by Alex Armstrong |
Tuesday, 27 November 2012 |
Oracle has proposed a new OpenJDK project to create a fast and lightweight JavaScript engine running on the JVM. The Nashorn project, German for Rhino, is being voted on now. The Rhino JavaScript engine, which is supported by Mozilla, already provides a Java implementation. It is written in Java and is often used to implement scripting within Java programs. The new project aims to make use of the modern additions to Java to speed things up.
As the proposal says: "we would like to start a new project to implement a lightweight high-performance JavaScript runtime in Java with a native JVM. This project intends to enable Java developers to embed JavaScript in Java applications via JSR-223 and to develop free standing JavaScript applications using the jrunscript command line tool." Despite the obvious temptation to incorporate existing code into the new project, the intention is to start a new code base. Since Rhino things have moved on in Java's ability to support dynamic languages and API calls such as InvokeDynamic should result in faster and more reliable code without the memory leaks that plagued Rhino. "The scope of this project will include, but is not limited to, a parser API for scanning JavaScript source code, a compiler to convert ASTs from the parser to JVM byte code, and a runtime to support the execution of said generated byte code." The target version of JavaScript is ECMA-262 and ECMAScript 5.1. Introduction to Nashorn
Oracle already has some code that it plans to share if the project is voted into existence. The vote is for current OpenJDK members and closed on December 6th. Nashorn looks to be mainly a replacement for Rhino as a way of embedding scripting into Java programs. However, if it is as fast as promised, other JavaScript projects such as Node.js might consider its use. JavaScript engines based on C/C++ are usually faster than even JIT-based JVMs, but the advantage in using a JVM based engine is the it is portable. Anywhere Java can run so can Rhino and soon Nashorn. JavaScript still hasn't really managed to break out of its clientside habitat despite the growing success of Node.js. Perhaps Nashorn will provide ways to run JavaScript not only in Java projects but on the desktop, in the server and perhaps in even in the browser. After all, Java byte code is a lot more sensible a choice as the assembler for the web than JavaScript - or is it?
More InformationRelated ArticlesJSFeat - JavaScript Image Processing Library JavaScript Is Basic's Offspring To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
|
Last Updated ( Wednesday, 28 November 2012 ) |