Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Rhinoceros on the Loose

The Rhinoceros on the Loose

JavaScript is a powerful, flexible, and dynamically typed language. JVM is proven to be reliable and stable production platform. The power of the JVM is an ability to run programs written in different languages, including JavaScript. You can short the development cycle by leveraging a scripting abilities of JavaScript. This presentation is about the emerging opensource frameworks that allow to mix Java and JavaScript in the same application.

In this session you'll get introduced to the latest state of the polyglot frameworks that use JavaScript and Java side-by-side. We'll discuss the following topics:

* The Nashorn benefits for the server and the client side developers.
* Using JavaScript and NodeJS libraries on the Java platform.
* Real-world projects overview that leveraging on Java-JavaScript interactions, including Avatar, Vertx and others.

Viktor Gamov

October 02, 2014
Tweet

More Decks by Viktor Gamov

Other Decks in Programming

Transcript

  1. www.faratasystems.com // follow me : twitter.com/gamussa
    Rhinoceros
    on the Loose
    Viktor Gamov
    Senior Software ENGINEER, Farata Systems
    Javaone, San Francisco, CA 2014
    Applied Real-World Projects with
    Java and JavaScript

    View full-size slide

  2. “May you live in interesting
    times”
    Chinese curse

    View full-size slide

  3. Why you’re here
    ★you're excited about JDK8 features

    View full-size slide

  4. Why you’re here
    ★you're excited about JDK8 features
    ★JavaScript enthusiast
    ★You could’t fit to Adam Bien’s Session

    View full-size slide

  5. Who is talking?
    ★Software engineer and consultant

    View full-size slide

  6. WE BUILD APPLICATIONS.
    WE CREATE IT. YOU OWN IT.

    View full-size slide

  7. Who is talking?
    ★Software engineer and consultant
    ★co-author and JUG co-lead

    View full-size slide

  8. DO you even javascript ?

    View full-size slide

  9. http://enterprisewebbook.com
    Available in stores

    View full-size slide

  10. http://enterprisewebbook.com

    View full-size slide

  11. Not-so-distant pasT
    Java devs about javascript
    I don’t care

    View full-size slide

  12. Present
    Java devs about javascript
    Gotta learn more

    View full-size slide


  13. print(3[3]);


    View full-size slide

  14. Number.prototype[3] = ”javaone”;

    print(3[3]);


    View full-size slide

  15. www.destroyallsoftware.com/talks/wat

    View full-size slide

  16. ScriptEngineManager factory = new ScriptEngineManager();

    ScriptEngine engine = factory.getEngineByName("nashorn");


    engine.eval("Number.prototype[3] = "javaone"; print(3[3]);")

    View full-size slide

  17. String[] options =

    new String[] {

    "--persistent-code-cache",

    "--class-cache-size=50",

    “—no-java"}; *

    NashornScriptEngineFactory factory = new NashornScriptEngineFactory();

    NashornScriptEngine engine =

    (NashornScriptEngine) factory.getScriptEngine(options);

    engine.eval("Number.prototype[3] = 'javaone'; print(3[3]);");
    * jjs -xhelp
    http://cr.openjdk.java.net/~sundar/jdk.nashorn.api/8u40/javadoc/jdk/nashorn/api/scripting/NashornScriptEngineFactory.html

    View full-size slide

  18. Avatar.js ftw!
    https://avatar-js.java.net

    View full-size slide

  19. Take first available express demo from
    internet what could go wrong

    View full-size slide

  20. https://github.com/hacksparrow/ninja-store

    View full-size slide

  21. NASHORN in «wild life»
    ★ vert.x
    ★ Avatar 2.0
    ★ nodyn.io

    View full-size slide

  22. ★polyglot platform
    ★Develop with Java, Javascript, jRuby, Groovy, jython, closure,
    ★Scala, php, ceylon
    ★integration with nashorn
    ★https://github.com/vert-x/mod-lang-nashorn
    ★Event bus (down to the browser)
    ★Distributed data (in v.3)
    ★Open source: EPL / Apache
    vertx.io

    View full-size slide

  23. Avatar 2.0
    ★polyglot platform (sort oF)
    ★integration with nashorn
    ★Node api
    ★Model-Store api
    ★Event bus
    ★Distributed data
    ★not open yet

    View full-size slide

  24. ★NODE api for Java platform
    ★USES DYNJS - ALTERNATIVE JAVASCRIPT
    ENGINE
    ★WILL BE INTEGRATED WITH VERTX
    nodyn

    View full-size slide

  25. Scalable JavaScript Applications with
    Project Nashorn [CON6423]
    Project Avatar: Server-Side JavaScript
    on the JVM [CON5675]
    1
    2
    3
    javaone 2014 taks to catch up
    Project Avatar: More Than Just Node.js
    on the JVM—Java EE Written in
    JavaScript [CON4091]
    4
    Toward Native JavaScript Performance
    on the JVM [CON4679]

    View full-size slide

  26. SHOW ME THE CODE
    https://github.com/gAmUssA/java-scripting-experiments

    View full-size slide

  27. THANKS
    FOR YOUR ATTENTION
    www.faratasystems.com // follow me : twitter.com/gamussa

    View full-size slide