Home arrow JavaScript arrow Project Nashorn to Make Java, JavaScript Work Together

Project Nashorn to Make Java, JavaScript Work Together

Oracle is putting its weight behind a new project aimed at making JavaScript work better with Java. Dubbed Project Nashorn, its goal is “to implement a lightweight high-performance JavaScript runtime in Java with a native JVM.”

Author Info:
By: Terri Wells
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
December 20, 2012

print this article

Oracle is putting its weight behind a new project aimed at making JavaScript work better with Java. Dubbed Project Nashorn, its goal is “to implement a lightweight high-performance JavaScript runtime in Java with a native JVM.”

You can check out details of the project here. Announced late last month, Project Nashorn boasts Jim Laskey from Oracle as the lead. The plan involves starting from scratch, using entirely new code. The initial source for it will come from an internal Oracle project. When complete, the project is supposed to let Java programmers embed JavaScript in Java apps using JSR-223 and develop freestanding JavaScript apps using the jrunscript command line.

So what will go into this project? Oracle's John Coomes, who posted the new project, explained that “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. Execution of JavaScript in this environment will be in conformance with ECMA-262 Edition 5.1 and will adapt to newer guidelines as standards evolve.”

The vote on whether to proceed with Project Nashorn was closed on midnight December 6. With 20 yeas, no vetoes, and no abstentions, the vote carried. The project now has its own page on OpenJDK. The project page gives a fuller historical context: “This Project is designed to take full advantage of newer technologies for native JVMs that have been made since the original development of JVM-based JavaScript with was started in 1997 by Netscape and maintained by Mozilla.”

Nashorn also has its own blog, run on an Oracle domain, but as of this writing it isn't very active. The last post, from Laskey himself, reported the results of the vote. But the two posts before that one gave copious examples of how Nashorn might work. Specifically, Laskey wanted to see how the name “Nashorn” was trending on the Internet, so he decided to write a program to count tweets. Using Nashorn with Java, he took advantage of the Twitter4J Java library and wrote a single line of code to start off his app. He then tied it to JavaFX to graph the result, and had to jump through some hoops to create the application. You can check out the specific blog entry for the full details.

So what, exactly, is the advantage of making Java and JavaScript work better together? Gavin Clarke writing for The Register, notes that “JavaScript runs in a browser but it execute in a JVM on the client or server has some benefits. It means apps written using JavaScript code can take advantage of a device or a server's CPU or GPU in performance.” This means that a JavaScript application won't be stuck depending on just the level of performance that the browser can give it.

Additionally, mixing Java and JavaScript could help Java to stay relevant. JavaScript isn't dying out any time soon, thanks to its ubiquitous usage in web-based programming. The problem is, it doesn't always run well on the server. Yes, you can use frameworks such as Node.JS, Jaxer, and Narwhal, but these often don't scale well. Project Nashorn could, potentially, be made to scale – depending on the enthusiasm it generates among open source programmers eager to work on it. As Clarke observes, “An official project from the OpenJDK at least stands the chance of becoming something people agree on using, and could offer the industry an alternative that attracts critical mass and which isn’t subject to the waxing and waning fads of frameworks and languages.” 

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

All JavaScript Tutorials
More By Terri Wells

blog comments powered by Disqus

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials