Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Java & JavaScript: Best Friends?

1,821 views

Published on

Talk from the SBB developers day 2014.

Published in: Software
  • Be the first to comment

Java & JavaScript: Best Friends?

  1. 1. Best Friends? jonas.bandi@gmail.com Twitter: @jbandi
  2. 2. <Experimental Code>
  3. 3. D Jonas Bandi 5 Years ago I had no clue about JavaScript Today JavaScript pays my bills
  4. 4. My Journey into JavaScript Land
  5. 5. I went through the five stages of grief.
  6. 6. Denial
  7. 7. Fear
  8. 8. Repulsion
  9. 9. Curiosity
  10. 10. Most of the people writing in JavaScript are not programmers. They lack the training and discipline to write good programs. - Douglas Crockford, 2001 The ecosystem around JavaScript as a serious application platform continues to evolve. - ThoughtWorks Technology Radar, January 2014 A very large group of developers still thinks of JavaScript as a joke. - Davy Brion, 2011 We strongly suggest to adopt JavaScript as a first class language. - ThoughtWorks Technology Radar, 2011 Through 2014, improved JavaScript performance will begin to push HTML5 and the browser as a mainstream enterprise application development environment. - Gartner, October 2013
  11. 11. Two Worlds?
  12. 12. Any application that can be written in JavaScript, will eventually be written in JavaScript. - Atwood’s Law, 2007
  13. 13. We are slaves to JavaScript because people have simply started to accept its weirdness and flaws, much like a Stockholm Syndrome phenomenon. - Chris Richardson, 2013
  14. 14. Best Friends
  15. 15. JavaScript is the Language of the Web. Another software technology will come along and kill off the web. That judgement day will arrive very soon. -Forrester Research in 2000 The Web has won!
  16. 16. HTML 5 HTML5 explained: • Html is the structure • CSS is the colour and style • JavaScript is everything else Scott Hanselman:Angle Brackets, Curly Braces http://channel9.msdn.com/Events/Build/2012/3-027
  17. 17. SPA Architecture View Model Controller Services ClientServer clear boundary "object model" • Rich client programming model in the browser • Clear separation of concern between client and server
  18. 18. JAVA EE
  19. 19. JAVA EE
  20. 20. JAVA EE 8: MVC (JSR 371) http://www.oracle.com/technetwork/articles/java/mvc-2280472.html JSFToday MVC in Java EE 8
  21. 21. DEMO: Debugging Seamless debugging between client and server with IntelliJ
  22. 22. Nashorn
  23. 23. JAVA SHIPS WITH JAVASCRIPT • Since Java SE 6, the JDK contains a JavaScript runtime. • In the JRE: Mozilla Rhino (JSR-223 or proprietary API) • In the JDK: jrunscript • Java 8 contains Nashorn • A completely rewritten JavaScript runtime on the JVM • Supports ECMAScript 5 and will support ECMAScript 6
  24. 24. DEMO: JJS System scripting Scripting Java Scripting a Java FX application
  25. 25. Demo: Embedding Nashorn Basic constructs: ScriptEngine, Invocable, Compilable A simple DSL realized in JavaScript Shared validation logic between client and server
  26. 26. Sharing Logic between 
 Client and Server View Controller Client Server Business Logic "Code Repository" Model
  27. 27. Project Avatar
  28. 28. Clients( Event(Loop( (single( thread,(non( blocking)( delegate(long( running(jobs( &(IO( callback( request( Workers(
  29. 29. Bower
  30. 30. AVATAR.JS https://avatar-js.java.net/ Avatar.js is a project to bring the node programming model,APIs and module ecosystem to the Java platform,
  31. 31. DEMO: avatar.js Running a node web-app with avatar.js Running a grunt build with avatar.js
  32. 32. PROJECT AVATAR https://avatar.java.net/ A JavaScript service layer on top of JavaEE and a client JS framework based on Java EL.
  33. 33. STATE OF PROJECT AVATAR • Announced by Oracle on JavaOne 2013 • Only available for Glassfish • Nothing happened after March 2014 • Does not run on latest releases of Glassfish/Java (at least on my machine)
  34. 34. AVATAR 2.0 • Oracle announced Avatar 2.0 on JavaOne 2014 • No Java EE application server needed • Runs in its own JVM, startable from commandline • No Client-Side Framework • Parallel event loops in several threads • Communication over message bus or shared state • A JavaScript Model Store API for persistence (based on EclipseLink) • Generally: Less Java EE more Node.js
  35. 35. STATE OF PROJECT AVATAR 2.0 • Announced by Oracle beginning October • Not available yet • No code on avatar.java.net • No release • Very similar to vert.x (vertx.io/)
  36. 36. PROJECT AVATAR unfortunately no demo...
  37. 37. Thank you for your attention. Discussions?

×