SlideShare a Scribd company logo
Scalable JavaScript applications with 
Project Nashorn
Speakers 
Leonardo Zanivan 
Software Architect, Trier Sistemas 
github.com/panga 
@leonardopanga 
Michel Graciano 
Software Architect, Betha Sistemas 
github.com/mgraciano 
@mgraciano
Agenda 
● Why JS in the server 
● Why the JVM 
● Nashorn ecosystem 
● Vert.x and Avatar/Avatar.js 
● Q&A
Why JS in the server 
● Asynchronous by nature 
● Native JSON support 
● Language reuse 
● Easier developer transition
Why the JVM 
● Multilanguage 
● APM Tools 
● Access to the Java ecosystem 
o Domain models already implemented 
o Java EE 
o Core and third parties Java libraries
Nashorn 
● JDK 8 Compact 1 Profile with extension 
● Restrictions (browsers API, DOM) 
● No native CommonJS implementation 
● ECMA 5.1 + Rhino compatibility 
● jjs interactive command line tool
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
Nashorn 
● JDK 8u20 
o JDK-8032068: sourceURL directives 
o JDK-8021350: Share script classes between 
threads/globals 
● JDK 8u40 
o JEP 196: Nashorn Optimistic Typing 
o JEP 202: Nashorn Class Filter 
o JEP 203: Initial ES6 implementation (const & let) 
● JEP 194: Nashorn Code Persistence (lazy compilation)
But how to scale it?
But how to scale it? 
Architectures and Technologies
Event-driven architecture 
● Event-loops 
● Async non-blocking IO 
● Reactive system 
● Event bus
Event-driven architecture
Microservice architecture 
● Focused on specific business 
● Well defined & distributed 
● Loosely coupled 
● Testable 
● Scalable
Microservices Architecture
Vert.x 
● http://vertx.io/ 
● Based on Netty 
● Sponsored by Red Hat 
● Winner of JAX Innovation Awards 2014 
@timfox: Writing Highly Concurrent Polyglot Applications with Vert.x 
[CON7902] Thursday, Oct 2, 11:30 AM
Vert.x 
● Key benefits 
o Polyglot 
o Event bus (async & worker verticles) 
o Create reactive applications 
o Microservices ready 
o Strong community involvement
Vert.x Architecture
Vert.x 
● Key benefits 
o Easy deployment 
 CLI, API, mods, runtime deps resolution 
o Good build tools support (fat jar, auto-redeploy) 
o Native Cluster & HA with Hazelcast 
o Tons of extensions available
Vert.x 
● Challenges 
o Updated documentation 
o Verticle monitoring 
o Limited transactions support 
o Doesn’t have distributed maps yet (2.x) 
o Nashorn debugging support (PR to be merged)
Vert.x 
● Vert.x 3 highlights 
o JDK 8+ with Nashorn & Lambda 
o No more module system* 
o Clustered shared data 
o Event bus proxies & codecs 
o Ext stack (MongoDB, SockJS, Route, Rx)
Demo 
● Real-time notification service using 
websockets over nashorn integrating with a 
legacy Java EE app
Avatar.js 
● https://avatar-js.java.net 
● Oracle sponsored 
● Focus on bringing the node programming 
model, APIs and module ecosystem to the 
Java platform
Avatar.js
Avatar 
● https://avatar.java.net 
● Oracle sponsored 
● Focus on Thin Server Architecture 
o Supports REST, WebSocket and Server-Sent 
Events 
● Built on Avatar.js
Avatar Architecture
Avatar EE Architecture
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
Avatar 
● Deploying an application on Glassfish 4 
o asadmin deploy ~/projects/<app-folder-name> 
● Running the application 
o http://localhost:8080/<app-folder-name>
Avatar/Avatar.js 
● Key benefits 
o Avatar Services use an Actor-like concurrency 
model 
o NPM modules support 
o Strong Java EE integration 
o Debugging
Avatar/Avatar.js 
● Challenges 
o Weak community involvement 
o Low activity and no stable release 
o Glassfish / Weblogic only 
o Model Store API supports only Oracle NoSQL for 
schemaless database
Benchmark 
● Some simple and naive scenarios 
o Posting and querying from database 
o Returning a simple JSON response 
o String concatenation 
o Fibonacci calculation
Benchmark 
● Node.js 0.10.29 (2014-06-16) 
● Avatar.js 0.10.28-SNAPSHOT (2014-07-20) 
● Vert.X 2.1.1 (2014-06-18) 
● Avatar 1.0-ea-SNAPSHOT (2014-07-26) 
● JDK 8u5
Some Fib(30) results
Some Fib(30) results
Some Fib(30) results
Q&A
Credits 
● Event-loop & Vert.X architecture 
o Slideshare presentation http://bit.ly/1qz6KUb 
● Microservice architecture 
o http://martinfowler.com/articles/microservices.html 
● Avatar.js architecture 
o Project Avatar.js website 
● Avatar and Avatar EE architectures 
o Project Avatar website
Thank you! 
@leonardopanga 
@mgraciano 
● Sources 
o github.com/mgraciano/javaone-2014 
o github.com/panga/javaone2014-benchmarks

More Related Content

PDF
Nashorn in the future (English)
PDF
Nashorn: JavaScript Running on Java VM (English)
PDF
Nashorn : JavaScript Running on Java VM (Japanese)
PDF
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
PPTX
Java EE for the Cloud
PDF
Java: Create The Future Keynote
PDF
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
PDF
Oracle Keynote from JMagghreb 2014
Nashorn in the future (English)
Nashorn: JavaScript Running on Java VM (English)
Nashorn : JavaScript Running on Java VM (Japanese)
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE for the Cloud
Java: Create The Future Keynote
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
Oracle Keynote from JMagghreb 2014

What's hot (20)

PDF
CompletableFuture уже здесь
PPTX
Configuration for Java EE and the Cloud
PDF
MySQL User Camp: GTIDs
PDF
JSONB introduction and comparison with other frameworks
PDF
Node.js und die Oracle-Datenbank
PDF
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
PDF
MySQL Developer Day conference: MySQL Replication and Scalability
PDF
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
PDF
Java EE 8 Overview (Japanese)
PDF
Open source India - MySQL Labs: Multi-Source Replication
PPTX
What's new in the Java API for JSON Binding
PDF
Cloud Native Java:GraalVM
PDF
MySQL User Camp: Multi-threaded Slaves
PDF
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
PPTX
HotSpotコトハジメ
PPTX
Functional programming with_jdk8-s_ritter
PDF
Configuration beyond Java EE 8
PDF
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
DOCX
Aneez Hasan_Resume
PDF
Intro To OSGi
CompletableFuture уже здесь
Configuration for Java EE and the Cloud
MySQL User Camp: GTIDs
JSONB introduction and comparison with other frameworks
Node.js und die Oracle-Datenbank
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
MySQL Developer Day conference: MySQL Replication and Scalability
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Java EE 8 Overview (Japanese)
Open source India - MySQL Labs: Multi-Source Replication
What's new in the Java API for JSON Binding
Cloud Native Java:GraalVM
MySQL User Camp: Multi-threaded Slaves
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
HotSpotコトハジメ
Functional programming with_jdk8-s_ritter
Configuration beyond Java EE 8
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
Aneez Hasan_Resume
Intro To OSGi
Ad

Viewers also liked (15)

PPTX
NetBeans Day 2016 - Getting the best of NetBeans IDE
PDF
NetBeans Day 2015 - Node.js, HTML5, JBoss Forge, and Other Awesome New NetBea...
PDF
TDC 2016 - Rodando JavaScript Server com Wildfly
PDF
TDC 2016 - Simplificando a segurança de sua aplicação com Java EE
PDF
O papel e a carreira do arquiteto de software
PDF
Curso Android Básico
PPTX
React e reactividade Meetup Facebook Developer Circles
PDF
Curso de ReactJS
PDF
JavaOne 2015 - Simplificando a segurança de sua aplicação com Java EE
PDF
React + Flux (Alt)
PDF
React Native na globo.com
PDF
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
PPTX
TDC2016SP - Trilha Frameworks JavaScript
PPTX
Vuejs Angularjs e Reactjs. Veja as diferenças de cada framework!
PDF
TDC 2014 - Arquitetura front-end com AngularJS
NetBeans Day 2016 - Getting the best of NetBeans IDE
NetBeans Day 2015 - Node.js, HTML5, JBoss Forge, and Other Awesome New NetBea...
TDC 2016 - Rodando JavaScript Server com Wildfly
TDC 2016 - Simplificando a segurança de sua aplicação com Java EE
O papel e a carreira do arquiteto de software
Curso Android Básico
React e reactividade Meetup Facebook Developer Circles
Curso de ReactJS
JavaOne 2015 - Simplificando a segurança de sua aplicação com Java EE
React + Flux (Alt)
React Native na globo.com
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
TDC2016SP - Trilha Frameworks JavaScript
Vuejs Angularjs e Reactjs. Veja as diferenças de cada framework!
TDC 2014 - Arquitetura front-end com AngularJS
Ad

Similar to JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423] (20)

PDF
CON6423: Scalable JavaScript applications with Project Nashorn
PDF
Dropwizard
PDF
Dropwizard
PPTX
Java Script recruiting
PPTX
Node.js Web Apps @ ebay scale
PDF
Node.js scaling in highload
PDF
The Java alternative to Javascript
PDF
GlassFish 3.1 at JCertif 2011
PDF
GlassFish Server 3.1: Deploying your Java EE 6 Applications
PDF
Cannibalising The Google App Engine
PDF
Red Hat Java Update and Quarkus Introduction
PPTX
Comparison between zookeeper, etcd 3 and other distributed coordination systems
PPTX
001. Introduction about React
PDF
OTN Developer Days - GlassFish
PDF
node.js 실무 - node js in practice by Jesang Yoon
PDF
20141111_SOS3_Gallo
PDF
Java EE6 CodeCamp16 oct 2010
PDF
Intro to creating kubernetes operators
PPTX
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
PDF
Modular Java applications with OSGi on Apache Karaf
CON6423: Scalable JavaScript applications with Project Nashorn
Dropwizard
Dropwizard
Java Script recruiting
Node.js Web Apps @ ebay scale
Node.js scaling in highload
The Java alternative to Javascript
GlassFish 3.1 at JCertif 2011
GlassFish Server 3.1: Deploying your Java EE 6 Applications
Cannibalising The Google App Engine
Red Hat Java Update and Quarkus Introduction
Comparison between zookeeper, etcd 3 and other distributed coordination systems
001. Introduction about React
OTN Developer Days - GlassFish
node.js 실무 - node js in practice by Jesang Yoon
20141111_SOS3_Gallo
Java EE6 CodeCamp16 oct 2010
Intro to creating kubernetes operators
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
Modular Java applications with OSGi on Apache Karaf

Recently uploaded (20)

PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
System and Network Administraation Chapter 3
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administration Chapter 2
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
AI in Product Development-omnex systems
PDF
top salesforce developer skills in 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administraation Chapter 3
ManageIQ - Sprint 268 Review - Slide Deck
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
System and Network Administration Chapter 2
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
AI in Product Development-omnex systems
top salesforce developer skills in 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Navsoft: AI-Powered Business Solutions & Custom Software Development
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
Online Work Permit System for Fast Permit Processing
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf

JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]

  • 1. Scalable JavaScript applications with Project Nashorn
  • 2. Speakers Leonardo Zanivan Software Architect, Trier Sistemas github.com/panga @leonardopanga Michel Graciano Software Architect, Betha Sistemas github.com/mgraciano @mgraciano
  • 3. Agenda ● Why JS in the server ● Why the JVM ● Nashorn ecosystem ● Vert.x and Avatar/Avatar.js ● Q&A
  • 4. Why JS in the server ● Asynchronous by nature ● Native JSON support ● Language reuse ● Easier developer transition
  • 5. Why the JVM ● Multilanguage ● APM Tools ● Access to the Java ecosystem o Domain models already implemented o Java EE o Core and third parties Java libraries
  • 6. Nashorn ● JDK 8 Compact 1 Profile with extension ● Restrictions (browsers API, DOM) ● No native CommonJS implementation ● ECMA 5.1 + Rhino compatibility ● jjs interactive command line tool
  • 14. Nashorn ● JDK 8u20 o JDK-8032068: sourceURL directives o JDK-8021350: Share script classes between threads/globals ● JDK 8u40 o JEP 196: Nashorn Optimistic Typing o JEP 202: Nashorn Class Filter o JEP 203: Initial ES6 implementation (const & let) ● JEP 194: Nashorn Code Persistence (lazy compilation)
  • 15. But how to scale it?
  • 16. But how to scale it? Architectures and Technologies
  • 17. Event-driven architecture ● Event-loops ● Async non-blocking IO ● Reactive system ● Event bus
  • 19. Microservice architecture ● Focused on specific business ● Well defined & distributed ● Loosely coupled ● Testable ● Scalable
  • 21. Vert.x ● http://vertx.io/ ● Based on Netty ● Sponsored by Red Hat ● Winner of JAX Innovation Awards 2014 @timfox: Writing Highly Concurrent Polyglot Applications with Vert.x [CON7902] Thursday, Oct 2, 11:30 AM
  • 22. Vert.x ● Key benefits o Polyglot o Event bus (async & worker verticles) o Create reactive applications o Microservices ready o Strong community involvement
  • 24. Vert.x ● Key benefits o Easy deployment  CLI, API, mods, runtime deps resolution o Good build tools support (fat jar, auto-redeploy) o Native Cluster & HA with Hazelcast o Tons of extensions available
  • 25. Vert.x ● Challenges o Updated documentation o Verticle monitoring o Limited transactions support o Doesn’t have distributed maps yet (2.x) o Nashorn debugging support (PR to be merged)
  • 26. Vert.x ● Vert.x 3 highlights o JDK 8+ with Nashorn & Lambda o No more module system* o Clustered shared data o Event bus proxies & codecs o Ext stack (MongoDB, SockJS, Route, Rx)
  • 27. Demo ● Real-time notification service using websockets over nashorn integrating with a legacy Java EE app
  • 28. Avatar.js ● https://avatar-js.java.net ● Oracle sponsored ● Focus on bringing the node programming model, APIs and module ecosystem to the Java platform
  • 30. Avatar ● https://avatar.java.net ● Oracle sponsored ● Focus on Thin Server Architecture o Supports REST, WebSocket and Server-Sent Events ● Built on Avatar.js
  • 35. Avatar ● Deploying an application on Glassfish 4 o asadmin deploy ~/projects/<app-folder-name> ● Running the application o http://localhost:8080/<app-folder-name>
  • 36. Avatar/Avatar.js ● Key benefits o Avatar Services use an Actor-like concurrency model o NPM modules support o Strong Java EE integration o Debugging
  • 37. Avatar/Avatar.js ● Challenges o Weak community involvement o Low activity and no stable release o Glassfish / Weblogic only o Model Store API supports only Oracle NoSQL for schemaless database
  • 38. Benchmark ● Some simple and naive scenarios o Posting and querying from database o Returning a simple JSON response o String concatenation o Fibonacci calculation
  • 39. Benchmark ● Node.js 0.10.29 (2014-06-16) ● Avatar.js 0.10.28-SNAPSHOT (2014-07-20) ● Vert.X 2.1.1 (2014-06-18) ● Avatar 1.0-ea-SNAPSHOT (2014-07-26) ● JDK 8u5
  • 43. Q&A
  • 44. Credits ● Event-loop & Vert.X architecture o Slideshare presentation http://bit.ly/1qz6KUb ● Microservice architecture o http://martinfowler.com/articles/microservices.html ● Avatar.js architecture o Project Avatar.js website ● Avatar and Avatar EE architectures o Project Avatar website
  • 45. Thank you! @leonardopanga @mgraciano ● Sources o github.com/mgraciano/javaone-2014 o github.com/panga/javaone2014-benchmarks

Editor's Notes

  • #11: Michel IEEE 754
  • #12: Michel Aqui posso demonstrar manualmente no jjs os comandos, jjs rodando um script e ainda no NetBeans rodando um script .js direto do source .java.
  • #13: Michel Aqui posso demonstrar manualmente no jjs os comandos, jjs rodando um script e ainda no NetBeans rodando um script .js direto do source .java.
  • #14: Michel Here is time to show how to use some Java 8 features inside a JS script. Here is just the tip of the iceberg, since we can use not just the Stream API, but we can use all the Collectors, Java and Time and so on.
  • #15: Michel Here the focus is not the JEPs individually, IMHO here I should talk about the Nashorn evolution and focus that Oracle has done here. Basically, tell to the audience that this is a new technology and it has and will be improved constantly.
  • #16: Michel 12/13’’ It is just a transitory slide and should be fast. The point here is to link the architectures and technologies slides that will be presented. The focus will be that architectures make possible to use different kind of technologies in different services, allowing the environment where you can have not only Java, but other languages as JS. That said, Avatar and Vert.x should be quoted as candidates for this kind of scenario as will be presented next.
  • #17: Michel 12/13’’ It is just a transitory slide and should be fast. The point here is to link the architectures and technologies slides that will be presented. The focus will be that architectures make possible to use different kind of technologies in different services, allowing the environment where you can have not only Java, but other languages as JS. That said, Avatar and Vert.x should be quoted as candidates for this kind of scenario as will be presented next.
  • #18: Leonardo Before we start talking about those technologies, we must understand the concepts behind it. The first one is that event-driven architecture it’s not much different than event-driven programming from desktop & mobile apps. The main concept are event-loops which runs in a single thread and handle requests to non blocking APIs or delegate long jobs to worker threads. Also you could have multiple event-loops in multiple threads. This kind of system is reactive, which means responsive, resilient, elastic and message driven. Responsive focus on providing faster and consistent response times, for better usability and user experience. Resilient remains responsive even after a failure with high availability and recovery. Elastic to maintain responsiveness with varying workloads with great scalability. Message driven to ensure loose coupling and asynchronous communication. In this scenario, the event bus is the mechanism to provide communication between nodes with different object models like a queue.
  • #19: Leonardo, 2/15” Here’s how event-driven architecture looks like. Client requests goes to the event loop which delegate jobs to worker threads after callbacks to the event loop to finally response to the client This architecture is present in NodeJS and also Vert.x and Avatar (we’ll talk about their soon) But unlike NodeJS, Vert.x and Avatar can have multi event loops and work well in cluster
  • #20: Leonardo Microservice architecture is the new buzzword of the SOA, but there isn’t a precise definition It’s a new term, but most of the techniques are known, among the common characteristics are: Service focused on specific business logic, also could have small and separate development teams It’s well defined and independent from other services, can use polyglot programming language and polyglot persistence (like JavaScript and MongoDB) Loose coupled, only depends on services interfaces and contracts It is testable if you do it in the right way Easily scalable with commodity hardware and with IaaS/PaaS providers But, there are many challenges of this kind of architecture like: Complex management and deployment, plus requires DevOps skills and automation scripts It has the same complexity of a distributed system, so the recommendation is to use it when it makes sense
  • #29: Michel
  • #30: Michel
  • #31: Michel
  • #32: Michel
  • #33: Michel
  • #36: Michel, 15/50’’
  • #37: Michel
  • #38: Michel, O tópico dos problemas com node_modules foi um comentário que eu fiz da dificuldade que eu tive de utilizar node_modules dentro do app, só conseguir fazer com módulos globais, APESAR de ter lido em algum lugar (que não lembro) que suportava dentro da aplicação, vale verificar ou remover isso da apresentação
  • #39: Michel Os benchmarks devem ser apresentados aqui. A dúvida é: vamos colocar isso antes ou depois do Demo?
  • #40: Michel Os benchmarks devem ser apresentados aqui. A dúvida é: vamos colocar isso antes ou depois do Demo?
  • #41: Michel
  • #42: Michel
  • #43: Michel, 5/55’’
  • #44: Leonardo Any questions?
  • #45: Leonardo Some credits from illustration
  • #46: Leonardo, 5/60” Here’re our twitter handles, feel free to contact us or talk after this session. Also the source codes were published including full Vert.x demo application and Vert.x & Avatar benchmarks. Thank you!