3. Rhino
• Slow compared to other Javascript Engines
(V8,Spidermonkey)
• Legacy Code (since 1998)
• Interpreted Code
• Non-compliant with ECMAScript (not 100%)
4. What is Nashorn?
• Started in 2011
• Embedded Javascript Engine
• Replacement of Rhino
• Open Source on the OpenJDK repository
• Released with JAVA 8
5. Possible use cases
• Shell Scripting
-jjs
• Desktop app Javascript
- Java Fx
• Server Side Javascript
- More later
• End-User Javascript
- Rule engines
- Etl
- Reporting Tools
..more
6. Nashorn Features
• ECMAScript-262 Edition 5.1 compliant
• JSR-292 “InvokeDynamic” (The Da Vinci Machine)
• Integrated with JSR-223 (Scripting for Java)
• Runtime Compiled to bytecode
• Small 1.5MB JAR
• Fast, 2x to 10x performance improvement
• Seamless Javascript/Java interoperability
12. Java.type
Given a name of a Java type, returns an object representing that type
in Nashorn. You can use with the new operator to create new
instances of the class as well as to access static members of the
class.
13. Java.extend
Java.extend function returns a type object for a subclass
of the specified Java class (or implementation of the
specified interface) that acts as a script-to-Java adapter
for it.
23. Avatar.js
• An open source project
• A server side Javascript framework for the JVM
• A mix of
- Node.js event driven model
- Nashorn Javascript engine
- Java platform APIs
• Brings “the Node programming model, APIs and
module ecosystem to the Java platform”.
24. Node.js
• Server side Javascript
• Based on Chrome V8 Engine
• Fast and Scalable
• Event driven, non-blocking I/O model
• Large community and adoption
-NPM ~70000 packages
27. Avatar.js Features
• Run node applications on the JVM
• Call any Java API from JavaScript
• Support multiple event loops
• Support multiple Java threads
30. Project Avatar
Project Avatar provides a JavaScript services layer
zeroed in on supporting REST, WebSockets and Server-
Sent Events, and a rich client side framework that
assumes very minor JavaScript knowledge. The services
side is focused on building data services using
JavaScript, while the optional client side is entirely
focused on supporting HTML5 and TSA (Thin Server
Architecture).
31. Project Avatar
• Server Side JavaScript Services Framework
• Focused on REST, WebSocket, Server Sent Event (SSE)
endpoints
• Node.js event-driven programming model
• Layers on Avatar.js Node-compatible runtime
• Integrated EE features
• Multi-threading
• Javascript Domain Model