SlideShare a Scribd company logo
1 of 22
Download to read offline
Java 8 JavaScript Nashorn
@MiroslavResetar, Javantura, 22.2.2014.
JavaScript na Javanturi?
•

Alfresco
•

•

CMIS API implementiran u JavaScriptu

Neo4J
•

„people love to use Neo4j from Node.js and the browser”

•

Sencha Touch, Ext.Js, D3.js,

•

JavaFX
•

•

Dart
•

•

„writing JavaFX scripts in Nashorn is very easy”

transkompajlira se u JavaScript!

Vert.x
•

JavaScript API
Popularnost JavaScripta?
• Redmonk, siječanj 2014.
• Github repozitoriji vs Stack Overflow

1.

JavaScript (+1)

2. Java (-1)
3. PHP
4. C# (+2)
5. Python (-1)
JVM polyglot programming
• Clojure, Scala, JRuby, Jython, Rhino (JavaScript)
• Zašto JVM?
• Jer je zakon
• GC, Threads, Java API, ogromna količina biblioteka, puno
platformi

• JVM – najbolji dio Jave 
Rhino
• Rhino – Java implementacija JavaScripta
• 1997 – Netscape započeo rad na Rhino-u

• 1998 – Rhino je predan Mozilli i open source-an
• 2006 – Java 6 pakira Rhino kao standardnu
implementaciju skriptnog jezika
Problemi sa Rhino-om
• Rhino je veoma spor u usporedbi sa ostalim JavaScript
engine-ima (browserima)
• Velika potrošnja memorije
• Veoma stari codebase (iz Java 1.1 vremena)
• Kako bi se „popravio” bio je potreban veliki rewrite,
odluka je bila krenuti iz početka
Nashorn
• Potpuno nova implementacija JavaScripta
• Kompajlirani kod a ne interpreter

• Dolazi standardno sa JDK-om 8
• 5 x manji footprint
• 20 x bolje performanse (otprilike )
Rhino vs Nashorn
Nashorn vs Groovy
InvokeDynamic
• A First Taste of InvokeDynamic
• „... static nature of Java is in the language itself (and not the
JVM)”
• „Every invocation has to be called against a known type.”
• „we must generate hundreds of tiny methods into tiny
classes with everything neatly tied up in a bow so the JVM
will pretty please perform that invocation for us as quickly
as possible”
•

„java.lang.OutOfMemoryError:

PermGen space”

• „InvokeDynamic ... the ability to make a dynamic call that
the JVM not only recognizes, but also optimizes in the same
way it optimizes plain old static-typed calls.”
•

MethodHandle happyTimeHandle = MethodHandles.findVirtual(Happy.class,
"happyTime", void.class, String.class);
Kako do Nashorn-a?
• JSR 223 – javax.script (Java 6, 12/2006)
Nashorn smoke test
QUnit
• „QUnit is a powerful, easy-to-use JavaScript unit testing

framework.”

• Dohvati engine, učitaj QUnit, setupiraj ga, pokreni test
{{Mustache}}
• „Mustache is a logic-less template syntax. It can be used for HTML,

config files, source code - anything. It works by expanding tags in a
template using values provided in a hash or object.”
Shell scripting: JJS
• Curl -> Regex -> Curl -> Play Audio
Što Nashor nije
• Nije DOM/CSS okruženje
• Ne podržava korištenje biblioteka kao što su JQuery, Dojo,
Ext. (out-of-the-box)

• Nema browser plugin API
• Nije embeddable u browser

• Ne podržava ne standardizirane feature JavaScripta
• Nije multithreaded safe
• generalno nije problem ukoliko se izbjegava globalni scope
• loadWithNewGlobal creates a fresh global before loading
the script
„Meet the team”
Jim Laskey odgovara
• Postoji li debugger za Nashorn?
• Debuger je integriran u Netbeans 8 (beta).
• Eclipse još nema debugger za Nashorn.

• Da li radite još na poboljšanju performansi?
• Da. Veliki trud se ulaže kako bi performanse bile još bolje sa
verzijom 8u20. Verzija se očekuje na jesen. Za sada su brojke
obećavajuće.

• Što se događa sa Node.jar projektom?
• Preimenovan u Avatar.js. StrongLoop ulažu ogroman trud ne
bi li podržali projekt. Trenutne performanse su bolje od
Node.js. Bit će još bolje sa verzijom 8u20.
Project Avatar i Avatar.js
• „Avatar.js is a project to bring the node programming model,
APIs and module ecosystem to the Java platform.”
• „Avatar.js applications are both asynchronous and singlethreaded (exactly as in Node.js).”
• „Avatar - JavaScript services layer...rich client side framework
that assumes very minor JavaScript knowledge.”
Želite znati više?
• Jim Laskey - Nashorn, JavaScript for the JVM
• http://www.youtube.com/watch?v=I6eo2KPsk7U

• Attila Szegedi - The Curious Case of JavaScript on the JVM
(http://vimeo.com/78890890)
• Oracle Java Magazine Jan/Feb 2014 – Oracle Nashorn
• http://julien.ponge.org/blog/nashorn-article-in-oraclejavamagazine-jan-feb-2014/
Pitanja?
Reference
• Kod - https://github.com/mresetar/javantura-nashorn
• JUnit benchmarks - http://labs.carrotsearch.com/junitbenchmarks-tutorial.html
• Nashorn JavaFx debugger https://github.com/wickund/nashornexamples/

• Spring boot sample project
• Rhino QUnit setup
• VoiceRSS service

More Related Content

What's hot

Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJSTim Sommer
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java Worldirbull
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoAziz Ali
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Migrate to JRuby
Migrate to JRubyMigrate to JRuby
Migrate to JRubyIan Yang
 
Running Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic BeanstalkRunning Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic Beanstalkzupzup.org
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event LoopTorontoNodeJS
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Edureka!
 
Scripting with NodeJS
Scripting with NodeJSScripting with NodeJS
Scripting with NodeJSBen Pearson
 

What's hot (20)

Nashorn
NashornNashorn
Nashorn
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java World
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
 
Intro to nodejs
Intro to nodejsIntro to nodejs
Intro to nodejs
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Migrate to JRuby
Migrate to JRubyMigrate to JRuby
Migrate to JRuby
 
Running Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic BeanstalkRunning Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic Beanstalk
 
NodeJS
NodeJSNodeJS
NodeJS
 
Understanding the Single Thread Event Loop
Understanding the Single Thread Event LoopUnderstanding the Single Thread Event Loop
Understanding the Single Thread Event Loop
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
Scripting with NodeJS
Scripting with NodeJSScripting with NodeJS
Scripting with NodeJS
 
Why JRuby?
Why JRuby?Why JRuby?
Why JRuby?
 
Nodejs
NodejsNodejs
Nodejs
 

Similar to Javantura 2014 - Java 8 JavaScript Nashorn

Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG RomaJava 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG RomaVitalij Zadneprovskij
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyEvgeny Rahman
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-finalLagergren jvmls-2014-final
Lagergren jvmls-2014-finalMarcus Lagergren
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesAlexandra Masterson
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby.toster
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJungryul Choi
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript ProgrammingYoshiki Shibukawa
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tourq3boy
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentationasync_io
 
Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Jamie Coleman
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Oscar Renalias
 
Node.js #digpen presentation
Node.js #digpen presentationNode.js #digpen presentation
Node.js #digpen presentationGOSS Interactive
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin ProgrammingAtlassian
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyajuckel
 

Similar to Javantura 2014 - Java 8 JavaScript Nashorn (20)

Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG RomaJava 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and Ruby
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-finalLagergren jvmls-2014-final
Lagergren jvmls-2014-final
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 
Jax keynote
Jax keynoteJax keynote
Jax keynote
 
Java (1)
Java (1)Java (1)
Java (1)
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, Future
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tour
 
GraalVM
GraalVMGraalVM
GraalVM
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019Are you ready for cloud-native java JavaCro2019
Are you ready for cloud-native java JavaCro2019
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013
 
Node.js #digpen presentation
Node.js #digpen presentationNode.js #digpen presentation
Node.js #digpen presentation
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

Javantura 2014 - Java 8 JavaScript Nashorn

  • 1. Java 8 JavaScript Nashorn @MiroslavResetar, Javantura, 22.2.2014.
  • 2. JavaScript na Javanturi? • Alfresco • • CMIS API implementiran u JavaScriptu Neo4J • „people love to use Neo4j from Node.js and the browser” • Sencha Touch, Ext.Js, D3.js, • JavaFX • • Dart • • „writing JavaFX scripts in Nashorn is very easy” transkompajlira se u JavaScript! Vert.x • JavaScript API
  • 3. Popularnost JavaScripta? • Redmonk, siječanj 2014. • Github repozitoriji vs Stack Overflow 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)
  • 4. JVM polyglot programming • Clojure, Scala, JRuby, Jython, Rhino (JavaScript) • Zašto JVM? • Jer je zakon • GC, Threads, Java API, ogromna količina biblioteka, puno platformi • JVM – najbolji dio Jave 
  • 5. Rhino • Rhino – Java implementacija JavaScripta • 1997 – Netscape započeo rad na Rhino-u • 1998 – Rhino je predan Mozilli i open source-an • 2006 – Java 6 pakira Rhino kao standardnu implementaciju skriptnog jezika
  • 6. Problemi sa Rhino-om • Rhino je veoma spor u usporedbi sa ostalim JavaScript engine-ima (browserima) • Velika potrošnja memorije • Veoma stari codebase (iz Java 1.1 vremena) • Kako bi se „popravio” bio je potreban veliki rewrite, odluka je bila krenuti iz početka
  • 7. Nashorn • Potpuno nova implementacija JavaScripta • Kompajlirani kod a ne interpreter • Dolazi standardno sa JDK-om 8 • 5 x manji footprint • 20 x bolje performanse (otprilike )
  • 10. InvokeDynamic • A First Taste of InvokeDynamic • „... static nature of Java is in the language itself (and not the JVM)” • „Every invocation has to be called against a known type.” • „we must generate hundreds of tiny methods into tiny classes with everything neatly tied up in a bow so the JVM will pretty please perform that invocation for us as quickly as possible” • „java.lang.OutOfMemoryError: PermGen space” • „InvokeDynamic ... the ability to make a dynamic call that the JVM not only recognizes, but also optimizes in the same way it optimizes plain old static-typed calls.” • MethodHandle happyTimeHandle = MethodHandles.findVirtual(Happy.class, "happyTime", void.class, String.class);
  • 11. Kako do Nashorn-a? • JSR 223 – javax.script (Java 6, 12/2006)
  • 13. QUnit • „QUnit is a powerful, easy-to-use JavaScript unit testing framework.” • Dohvati engine, učitaj QUnit, setupiraj ga, pokreni test
  • 14. {{Mustache}} • „Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.”
  • 15. Shell scripting: JJS • Curl -> Regex -> Curl -> Play Audio
  • 16. Što Nashor nije • Nije DOM/CSS okruženje • Ne podržava korištenje biblioteka kao što su JQuery, Dojo, Ext. (out-of-the-box) • Nema browser plugin API • Nije embeddable u browser • Ne podržava ne standardizirane feature JavaScripta • Nije multithreaded safe • generalno nije problem ukoliko se izbjegava globalni scope • loadWithNewGlobal creates a fresh global before loading the script
  • 18. Jim Laskey odgovara • Postoji li debugger za Nashorn? • Debuger je integriran u Netbeans 8 (beta). • Eclipse još nema debugger za Nashorn. • Da li radite još na poboljšanju performansi? • Da. Veliki trud se ulaže kako bi performanse bile još bolje sa verzijom 8u20. Verzija se očekuje na jesen. Za sada su brojke obećavajuće. • Što se događa sa Node.jar projektom? • Preimenovan u Avatar.js. StrongLoop ulažu ogroman trud ne bi li podržali projekt. Trenutne performanse su bolje od Node.js. Bit će još bolje sa verzijom 8u20.
  • 19. Project Avatar i Avatar.js • „Avatar.js is a project to bring the node programming model, APIs and module ecosystem to the Java platform.” • „Avatar.js applications are both asynchronous and singlethreaded (exactly as in Node.js).” • „Avatar - JavaScript services layer...rich client side framework that assumes very minor JavaScript knowledge.”
  • 20. Želite znati više? • Jim Laskey - Nashorn, JavaScript for the JVM • http://www.youtube.com/watch?v=I6eo2KPsk7U • Attila Szegedi - The Curious Case of JavaScript on the JVM (http://vimeo.com/78890890) • Oracle Java Magazine Jan/Feb 2014 – Oracle Nashorn • http://julien.ponge.org/blog/nashorn-article-in-oraclejavamagazine-jan-feb-2014/
  • 22. Reference • Kod - https://github.com/mresetar/javantura-nashorn • JUnit benchmarks - http://labs.carrotsearch.com/junitbenchmarks-tutorial.html • Nashorn JavaFx debugger https://github.com/wickund/nashornexamples/ • Spring boot sample project • Rhino QUnit setup • VoiceRSS service