Server-Side JavaScript
with Nashorn
Dan Woods
@danveloper
About Me
Author for InfoQ /danveloper
danielpwoods@gmail.com
Intro
My Experiences with PhotoZero!
!
• A client-side file encryption service
!
• Allowed clients to security unlock files/photos with
confidence
!
• Server never knew about the content or password
that a user was uploading, only its chunks in the
position
!
• Salted unlock keys were encrypted to double-down
on security
File
Intro
General PhotoZero Overview
Chunks
PZERO
Chunking
Engine
Chunk
Chunk
Chunk
Chunk
Server
Encryptor
Encryptor
Encryptor
Encryptor
DB
Backgrounding: https://github.com/danveloper/jquery-bqep-plugin
Intro
PhotoZero & How I came to Server-Side
JavaScript!
!
• Client entirely in HTML5 JavaScript
!
• Decorated with JQuery (some good, mostly bad)
!
• Server-side was implemented on the JVM (Grails)
!
• Non-common language between front-end and
back-end didn’t feel right
Intro
Rhino!
!
• Started by Netscape in 1997
!
• Originally designed as Netscape’s (ahem…)
Javagator
!
• Code generation, memory leaks, slow compilation
times
Intro
What is Nashorn?!
!
• The Better-than-Rhino JVM JavaScript Engine
!
• Comes out-of-the-box with Java 8 and above
!
• Replacement for Rhino
Intro
The Need for Nashorn!
!
• JVM is a polyglot platform
!
• Rhino is old
!
• Comparatively, Rhino is quite slow
!
• ECMAScript compliance
Intro
The How of Nashorn!
!
• Truly practical JavaScript on the JVM was not
possible until Java 7
!
• Java 7’s invokeDynamic gives static linking to
dynamic languages (incl. JavaScript)
!
• JVM dynamic languages have runtime support in
method dispatching, without runtime costs
Engine Features
Nashorn Features!
!
• 100% ECMAScript 5.1 compliance
!
• Support for a few extensions
• function expression closures - Mozilla 1.8,
• for-each expressions - Mozilla 1.6,
• Rhino constructor extensions
!
• Powerful CLI (jjs) for building command-line scripts!
Use Cases
Avatar.js and node.jar!
!
• Avatar is a web framework that brings Node-style
syntax and programming to the JVM
!
• Written by Oracle as a code-gen’d bridge to HTML5
apps
!
• Event-driven support for html web server, SSE
spec, websockets
Use Cases
Avatar.js and node.jar!
!
• Respects your Node modules paths, so you can
npm install in the same way
!
• Note: v8 and Nashorn have different ideas about
what the Error class does… I’ve built a “fix”
Use Cases
Java Interoperability!
!
• Java has a great modularity story, and its ability to
compose libraries is a huge value to JavaScript
!
• Java has a long history and has figured out
solutions to a lot of the problems of server-side
development
!
• Nashorn’s dynamic linking brings performance with
interoperability; JavaScript methods can be
seamlessly linked and vice-versa
Use Cases
What has Java Done Right?!
!
• For better or worse: databases and persistence
!
• Threads; we can’t just ignore these things! They’re
useful!
!
• Right Tool For The Job (tm) — JVM languages
!
• Embedded systems
!
• Build systems (Maven, Gradle, SBT, Ant, etc…)
Use Cases
Why Should I Care?!
!
• This platform of interop allows you to use best-of-
breed for the job
!
• Gives you an avenue to refactor existing code to
more sensible JavaScript
!
• Garner all the tooling and monitoring of JMX and
Java instrumentation
Use Cases
Server Side Scripting!
!
• Nashorn ships with a script runner (jjs)
!
• Allows server scripts to be written with JavaScript
!
• Special syntax for falling back to shell, and ability to
capture that output (very Perl-like)
Use Cases
Performance!
!
• Java 8 introduced practical JavaScript on the JVM
!
• Performance & Compliance is at the forefront, but
the former is still not quite there
!
• The near-term roadmap for the JVM brings
performance enhancements to Nashorn
Performance
Performance!
!
• Soon, JavaScript on the JVM will run at near-native
performance levels!
!
• This update will come as part of Java 8u40
The Future
The Future…!
!
• Nashorn will make the JVM a platform for
performant dynamic languages, targeting native-
like performance
!
• Java 8 will continue to improve upon JavaScript’s
server-side performance, and will offer other
languages the same performance

More Related Content

PPTX
Nashorn: JavaScript that doesn’t suck (ILJUG)
PDF
Javantura 2014 - Java 8 JavaScript Nashorn
PDF
Webconf nodejs-production-architecture
PDF
Java/Spring과 Node.js의 공존 시즌2
PPTX
Introduction to node.js by jiban
PDF
Understanding the Single Thread Event Loop
PPTX
NodeJS - Server Side JS
PPT
Introduction to node.js aka NodeJS
Nashorn: JavaScript that doesn’t suck (ILJUG)
Javantura 2014 - Java 8 JavaScript Nashorn
Webconf nodejs-production-architecture
Java/Spring과 Node.js의 공존 시즌2
Introduction to node.js by jiban
Understanding the Single Thread Event Loop
NodeJS - Server Side JS
Introduction to node.js aka NodeJS

What's hot (20)

PPTX
Introduction to node.js
PDF
9 anti-patterns for node.js teams
PDF
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
PDF
Complete MVC on NodeJS
PDF
Introduction to Node.js
PDF
Node.js in a heterogeneous system
PDF
Introduction to Node.js: What, why and how?
PDF
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
PDF
Basic Understanding and Implement of Node.js
PDF
Webアプリケーションとメモリ
PPTX
Server::Starter meets Java
PPTX
Introduction to Node.js
PDF
Node.js for beginner
PDF
NodeJS ecosystem
PPTX
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
PDF
Running JavaScript Efficiently in a Java World
PPTX
Node.js, for architects - OpenSlava 2013
PDF
Golang @ Tokopedia
PDF
Lagergren jvmls-2013-final
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Introduction to node.js
9 anti-patterns for node.js teams
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Complete MVC on NodeJS
Introduction to Node.js
Node.js in a heterogeneous system
Introduction to Node.js: What, why and how?
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Basic Understanding and Implement of Node.js
Webアプリケーションとメモリ
Server::Starter meets Java
Introduction to Node.js
Node.js for beginner
NodeJS ecosystem
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Running JavaScript Efficiently in a Java World
Node.js, for architects - OpenSlava 2013
Golang @ Tokopedia
Lagergren jvmls-2013-final
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Ad

Viewers also liked (20)

PDF
A new execution model for Nashorn in Java 9
PDF
진큐 오버뷰
PDF
Framtidens ehandel redan idag
PPSX
9no a 2da version
PDF
Weekly plannig52012
PPTX
Introducción a la CMNUCC
PPTX
Professional scepticism judgment uia 2
PPTX
Convertible Leasing Guide
PPTX
Свято 8 Березня в середній групі "Ромашка" ДНЗ № 28 м. Мукачево
PDF
Evolucion de la informatica y su aplicacion
PPTX
INTRODUCCIÓN A LA COMUNICACIÓN CIENTIFÍCA
PPTX
Introducción a la Biotecnología. Capítulo 2
PDF
Introducción a la cerámica popular canaria cuadernillo
PPTX
Worcester Food & Active Living Policy Council: An Introduction
PPT
Guitar 5th grade
PDF
Introducción a la ciencia e ingeniería de los materiales william d. callist...
PDF
8th pre alg -jan22
PDF
IntroduccióN A La ClíNica PsicolóGica Con NiñOs
PDF
Innovation in digital schools Gess Dubai 2013
A new execution model for Nashorn in Java 9
진큐 오버뷰
Framtidens ehandel redan idag
9no a 2da version
Weekly plannig52012
Introducción a la CMNUCC
Professional scepticism judgment uia 2
Convertible Leasing Guide
Свято 8 Березня в середній групі "Ромашка" ДНЗ № 28 м. Мукачево
Evolucion de la informatica y su aplicacion
INTRODUCCIÓN A LA COMUNICACIÓN CIENTIFÍCA
Introducción a la Biotecnología. Capítulo 2
Introducción a la cerámica popular canaria cuadernillo
Worcester Food & Active Living Policy Council: An Introduction
Guitar 5th grade
Introducción a la ciencia e ingeniería de los materiales william d. callist...
8th pre alg -jan22
IntroduccióN A La ClíNica PsicolóGica Con NiñOs
Innovation in digital schools Gess Dubai 2013
Ad

Similar to Server-Side JavaScript with Nashorn (20)

PPT
Nashorn
PDF
Isomorphic JavaScript with Nashorn
PDF
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
PDF
Nashorn in the future (English)
PDF
Java & JavaScript: Best Friends?
PDF
Java 8 new features
PDF
Java 8 new features
PDF
JavaOne 2014: Java vs JavaScript
PPTX
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
PDF
Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
KEY
RingoJS: Server-Side Javascript When Only Java Will Do
PDF
IBM InterConnect: Java vs JavaScript for Enterprise WebApps
PDF
Nashorn in the future (English)
PDF
Why and How You Should Move from PHP to Node.js
PPTX
JCConf2019: Next Step of JavaScript on Java
PDF
JavaScript isn't evil.
PDF
Nashorn: JavaScript Running on Java VM (English)
PDF
Nashorn - JavaScript on the JVM - Akhil Arora
PDF
Progressive web and the problem of JavaScript
PDF
JavaScript for Enterprise Applications
Nashorn
Isomorphic JavaScript with Nashorn
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Nashorn in the future (English)
Java & JavaScript: Best Friends?
Java 8 new features
Java 8 new features
JavaOne 2014: Java vs JavaScript
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
RingoJS: Server-Side Javascript When Only Java Will Do
IBM InterConnect: Java vs JavaScript for Enterprise WebApps
Nashorn in the future (English)
Why and How You Should Move from PHP to Node.js
JCConf2019: Next Step of JavaScript on Java
JavaScript isn't evil.
Nashorn: JavaScript Running on Java VM (English)
Nashorn - JavaScript on the JVM - Akhil Arora
Progressive web and the problem of JavaScript
JavaScript for Enterprise Applications

More from Daniel Woods (14)

PPTX
Continuous Delivery with Spinnaker and OpenStack
PDF
High Performance Microservices with Ratpack and Spring Boot
PDF
Groovy in the Cloud
PPTX
Ratpack - SpringOne2GX 2015
PDF
Ratpack Web Framework
PPTX
Microservices: The Right Way
PDF
Ratpack Web Framework
PDF
Facilitating Continuous Delivery at Scale
PDF
Continuous Delivery with NetflixOSS
PDF
Future of Grails
PPTX
Groovy for System Administrators
PPTX
Message Driven Architecture in Grails
PPTX
Building Web Apps in Ratpack
PDF
Gainesville Web Developer Group, Sept 2012
Continuous Delivery with Spinnaker and OpenStack
High Performance Microservices with Ratpack and Spring Boot
Groovy in the Cloud
Ratpack - SpringOne2GX 2015
Ratpack Web Framework
Microservices: The Right Way
Ratpack Web Framework
Facilitating Continuous Delivery at Scale
Continuous Delivery with NetflixOSS
Future of Grails
Groovy for System Administrators
Message Driven Architecture in Grails
Building Web Apps in Ratpack
Gainesville Web Developer Group, Sept 2012

Recently uploaded (20)

PDF
Understand the Gitlab_presentation_task.pdf
PPTX
Viva Digitally Software-Defined Wide Area Network.pptx
PDF
Alethe Consulting Corporate Profile and Solution Aproach
PPTX
AI_Cyberattack_Solutions AI AI AI AI .pptx
PPT
12 Things That Make People Trust a Website Instantly
PPTX
Layers_of_the_Earth_Grade7.pptx class by
DOCX
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
PPTX
Cyber Hygine IN organizations in MSME or
PDF
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
PPTX
1402_iCSC_-_RESTful_Web_APIs_--_Josef_Hammer.pptx
PPTX
Artificial_Intelligence_Basics use in our daily life
PPTX
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
PPTX
Basic understanding of cloud computing one need
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PDF
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
PPTX
The-Importance-of-School-Sanitation.pptx
PPTX
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
PDF
simpleintnettestmetiaerl for the simple testint
PPTX
Tìm hiểu về dịch vụ FTTH - Fiber Optic Access Node
PPTX
t_and_OpenAI_Combined_two_pressentations
Understand the Gitlab_presentation_task.pdf
Viva Digitally Software-Defined Wide Area Network.pptx
Alethe Consulting Corporate Profile and Solution Aproach
AI_Cyberattack_Solutions AI AI AI AI .pptx
12 Things That Make People Trust a Website Instantly
Layers_of_the_Earth_Grade7.pptx class by
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
Cyber Hygine IN organizations in MSME or
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
1402_iCSC_-_RESTful_Web_APIs_--_Josef_Hammer.pptx
Artificial_Intelligence_Basics use in our daily life
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
Basic understanding of cloud computing one need
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
The-Importance-of-School-Sanitation.pptx
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
simpleintnettestmetiaerl for the simple testint
Tìm hiểu về dịch vụ FTTH - Fiber Optic Access Node
t_and_OpenAI_Combined_two_pressentations

Server-Side JavaScript with Nashorn

  • 2. About Me Author for InfoQ /danveloper danielpwoods@gmail.com
  • 3. Intro My Experiences with PhotoZero! ! • A client-side file encryption service ! • Allowed clients to security unlock files/photos with confidence ! • Server never knew about the content or password that a user was uploading, only its chunks in the position ! • Salted unlock keys were encrypted to double-down on security
  • 5. Intro PhotoZero & How I came to Server-Side JavaScript! ! • Client entirely in HTML5 JavaScript ! • Decorated with JQuery (some good, mostly bad) ! • Server-side was implemented on the JVM (Grails) ! • Non-common language between front-end and back-end didn’t feel right
  • 6. Intro Rhino! ! • Started by Netscape in 1997 ! • Originally designed as Netscape’s (ahem…) Javagator ! • Code generation, memory leaks, slow compilation times
  • 7. Intro What is Nashorn?! ! • The Better-than-Rhino JVM JavaScript Engine ! • Comes out-of-the-box with Java 8 and above ! • Replacement for Rhino
  • 8. Intro The Need for Nashorn! ! • JVM is a polyglot platform ! • Rhino is old ! • Comparatively, Rhino is quite slow ! • ECMAScript compliance
  • 9. Intro The How of Nashorn! ! • Truly practical JavaScript on the JVM was not possible until Java 7 ! • Java 7’s invokeDynamic gives static linking to dynamic languages (incl. JavaScript) ! • JVM dynamic languages have runtime support in method dispatching, without runtime costs
  • 10. Engine Features Nashorn Features! ! • 100% ECMAScript 5.1 compliance ! • Support for a few extensions • function expression closures - Mozilla 1.8, • for-each expressions - Mozilla 1.6, • Rhino constructor extensions ! • Powerful CLI (jjs) for building command-line scripts!
  • 11. Use Cases Avatar.js and node.jar! ! • Avatar is a web framework that brings Node-style syntax and programming to the JVM ! • Written by Oracle as a code-gen’d bridge to HTML5 apps ! • Event-driven support for html web server, SSE spec, websockets
  • 12. Use Cases Avatar.js and node.jar! ! • Respects your Node modules paths, so you can npm install in the same way ! • Note: v8 and Nashorn have different ideas about what the Error class does… I’ve built a “fix”
  • 13. Use Cases Java Interoperability! ! • Java has a great modularity story, and its ability to compose libraries is a huge value to JavaScript ! • Java has a long history and has figured out solutions to a lot of the problems of server-side development ! • Nashorn’s dynamic linking brings performance with interoperability; JavaScript methods can be seamlessly linked and vice-versa
  • 14. Use Cases What has Java Done Right?! ! • For better or worse: databases and persistence ! • Threads; we can’t just ignore these things! They’re useful! ! • Right Tool For The Job (tm) — JVM languages ! • Embedded systems ! • Build systems (Maven, Gradle, SBT, Ant, etc…)
  • 15. Use Cases Why Should I Care?! ! • This platform of interop allows you to use best-of- breed for the job ! • Gives you an avenue to refactor existing code to more sensible JavaScript ! • Garner all the tooling and monitoring of JMX and Java instrumentation
  • 16. Use Cases Server Side Scripting! ! • Nashorn ships with a script runner (jjs) ! • Allows server scripts to be written with JavaScript ! • Special syntax for falling back to shell, and ability to capture that output (very Perl-like)
  • 17. Use Cases Performance! ! • Java 8 introduced practical JavaScript on the JVM ! • Performance & Compliance is at the forefront, but the former is still not quite there ! • The near-term roadmap for the JVM brings performance enhancements to Nashorn
  • 18. Performance Performance! ! • Soon, JavaScript on the JVM will run at near-native performance levels! ! • This update will come as part of Java 8u40
  • 19. The Future The Future…! ! • Nashorn will make the JVM a platform for performant dynamic languages, targeting native- like performance ! • Java 8 will continue to improve upon JavaScript’s server-side performance, and will offer other languages the same performance