Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
Marcus Lagergren | OracleWhy dynamic languageson the JVM matter[and project Nashorn]
The Legal Slide"THE FOLLOWING IS INTENDED TO OUTLINE OUR GENERALPRODUCT DIRECTION. IT IS INTENDED FOR INFORMATIONPURPOSES ...
Who am I?@lagergren
I am here to talk about…The Java Runtime:The JVM
I am here to talk about…The Universal Meta-execution environment
I am here to talk about…The Universal Meta-execution environment
I am here to talk about…The JVM as a multi-language runtime
I am here to talk about…The JVM as a multi-language runtime(especially in the context of dynamic languages)
History(what is a runtime, anyway?)
LISP
LISP1950s – First compiler in 1962
LISPJust-in-time compilation
LISPJust-in-time compilation
LISPAlso – Garbage Collection!
LISPAlso – Garbage Collection!
Smalltalk
SmalltalkFirst class library.
SmalltalkFirst class library. First visual GUIdriven IDE.
SmalltalkFirst class library. First visual GUIdriven IDE. Bytecode.
SmalltalkFirst class library. First visual GUIdriven IDE. Bytecode.
Emerging(dynamic)Languages
Dynamic languagesActionScript Adenine APL BASICBeanShell Clojure ColdFusion DartDylan Groovy E Fancy JavaScriptJulia Lua M...
Dynamic languagesActionScript Adenine APL BASICBeanShell Clojure ColdFusion DartDylan Groovy E Fancy JavaScriptJulia Lua M...
Dynamic languages•  Dynamic languages are hot today because–  They are easy to use–  Have no explicit compile stage–  Have...
Trendy Dynamic Languages
Trendy Dynamic Languages
Trendy Dynamic Languages
Trendy Dynamic Languages
Trendy Dynamic LanguagesAlready on top of the JVM
…and of courseV8, Futhark, Carakan, SpiderMonkey,JägerMonkey, *Monkey, Nitro, Rhino,Nashorn, etc etc
Putting yourlanguage on top ofthe JVM
Why?•  You get so much for free!–  Automatic memory management–  State of the art JIT optimizations–  Native threading cap...
Why?0100000200000300000400000500000Code basesLines
Why?0100000200000300000400000500000Code basesLinesIf it were all about code complexity – TOTALLY WORTH IT!
“All problems in computer science can be solvedby another level of indirection”- David Wheeler
Sounds good – implement it!•  Just serve up some bytecode•  People have been doing it since 1996
They have been doing it a lot,actually…FantomFortressBeanShellJaskellANTLRJudoScriptABCLErjangX10jdartjgoNiceGosuJacl
“All problems in computer science can be solvedby another level of indirection”- David Wheeler
“All problems in computer science can be solvedby another level of indirection”- David Wheeler“Except for the problem of t...
So why is it hard?
So why is it hard?•  “Java bytecode”–  Notice the “Java”•  There are “classes”, “methods”, sizelimitations, strong types• ...
So why is it hard?•  Different levels of “hard”•  Square peg, round hole or round peg, ovalhole•  Scala is a fairly good f...
Not every language hasexactly 5 strong typesint, float, long, double, Object
Not every language hasexactly 5 strong typesint sum(int a, int b) {return a + b;}int, float, long, double, Object
Not every language hasexactly 5 strong typesint, float, long, double, Objectiload_1iload_2iaddireturn
Not every language hasexactly 5 strong typesint, float, long, double, Objectfunction sum(a, b) {return a + b;}
Not every language hasexactly 5 strong typesint, float, long, double, Object????????????
Not every language hasexactly 5 strong typesint, float, long, double, Object????????????
Also: It is hard toswap out codewith other code
Also: It is hard toswap out codewith other code
Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?
Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?•  Passive–  Just wa...
Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?•  Passive–  Just wa...
Punch through the indirectionlayerinvokedynamic is my ice pick
Invokedynamic•  Breaks the constraints of Java calls andlinkage•  Can implement calls that act like functionpointers•  Mor...
The whole point:The JVM canoptimize this!
The NashornProject(a Rhino for 2013)
Rationale•  Proof of concept: invokedynamic•  Does it provide all required functionality?•  Does it perform?•  Back in lat...
Rationale – JavaScript?•  Extremely dynamic–  All (well, most) getters, setters, calls have to beinvokedynamics•  Rhino is...
Full ECMAScript Compliance
Full ECMAScript Compliance
Performancerhino	0	2000	4000	6000	8000	10000	12000	rhino	nashorn
Performancerhino	0	2000	4000	6000	8000	10000	12000	rhino	nashorn
Further POC: node.jar•  A node.js implmentation in only Java andJavaScript–  Forked the original node.js – threw out all n...
Nashorn already in OpenJDK 8Now: more Nashorn & JVM performanceenhancementsNow: more powerful hybrid proof ofconcepts, e.g...
Contribute!1.  Ask the community to contributefunctionality, testing, performance [analysis],bug fixes, library optimizati...
The Da VinciMachine (MLVM)
Can we do better than the icepick?Reshape the hole!
Let’s continue building our“future VM”•  An open source incubator forJVM futures•  Contains code fragments(patches)•  Migr...
It’s more than justinvokedynamic•  Unified type systems•  Pluggable frontends, “bytecode 2.0”•  Tail calls•  (delimited) C...
Da Vinci Machine Patches
It’s not just invokedynamicThe JVM is evolving to become themulti-language runtime
Danke![Hopefully, I’ll see you again at theNashorn / invokedynamic deep dive 16.45 thisafternoon]@lagergren
Jax keynote
Jax keynote
Jax keynote
Jax keynote
Jax keynote
Jax keynote
Upcoming SlideShare
Loading in …5
×

Jax keynote

2,322 views

Published on

Keynote I did at JAX2013 with the topic basically being "the JVM is over - enter the Polyglot Runtime". It is about the work that Oracle and the community is doing to facilitate multiple languages (non Java) on the Java Virtual Machine. This is both relevant for dynamic languages as well as "non dynamic" ones.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,322
On SlideShare
0
From Embeds
0
Number of Embeds
53
Actions
Shares
0
Downloads
23
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Jax keynote

  1. 1. Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
  2. 2. Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
  3. 3. Marcus Lagergren | OracleWhy dynamic languageson the JVM matter
  4. 4. Marcus Lagergren | OracleWhy dynamic languageson the JVM matter[and project Nashorn]
  5. 5. The Legal Slide"THE FOLLOWING IS INTENDED TO OUTLINE OUR GENERALPRODUCT DIRECTION. IT IS INTENDED FOR INFORMATIONPURPOSES ONLY, AND MAY NOT BE INCORPORATED INTOANY CONTRACT. IT IS NOT A COMMITMENT TO DELIVER ANYMATERIAL, CODE, OR FUNCTIONALITY, AND SHOULD NOT BERELIED UPON IN MAKING PURCHASING DECISION. THEDEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURESOR FUNCTIONALITY DESCRIBED FOR ORACLES PRODUCTSREMAINS AT THE SOLE DISCRETION OF ORACLE."
  6. 6. Who am I?@lagergren
  7. 7. I am here to talk about…The Java Runtime:The JVM
  8. 8. I am here to talk about…The Universal Meta-execution environment
  9. 9. I am here to talk about…The Universal Meta-execution environment
  10. 10. I am here to talk about…The JVM as a multi-language runtime
  11. 11. I am here to talk about…The JVM as a multi-language runtime(especially in the context of dynamic languages)
  12. 12. History(what is a runtime, anyway?)
  13. 13. LISP
  14. 14. LISP1950s – First compiler in 1962
  15. 15. LISPJust-in-time compilation
  16. 16. LISPJust-in-time compilation
  17. 17. LISPAlso – Garbage Collection!
  18. 18. LISPAlso – Garbage Collection!
  19. 19. Smalltalk
  20. 20. SmalltalkFirst class library.
  21. 21. SmalltalkFirst class library. First visual GUIdriven IDE.
  22. 22. SmalltalkFirst class library. First visual GUIdriven IDE. Bytecode.
  23. 23. SmalltalkFirst class library. First visual GUIdriven IDE. Bytecode.
  24. 24. Emerging(dynamic)Languages
  25. 25. Dynamic languagesActionScript Adenine APL BASICBeanShell Clojure ColdFusion DartDylan Groovy E Fancy JavaScriptJulia Lua MATLAB Objective-C PerlPHP Powershell Python Qore RREBOL REXX Ruby SchemeSmalltalk Snit Tcl VBScript Yoix etcetc etc etc…
  26. 26. Dynamic languagesActionScript Adenine APL BASICBeanShell Clojure ColdFusion DartDylan Groovy E Fancy JavaScriptJulia Lua MATLAB Objective-C PerlPHP Powershell Python Qore RREBOL REXX Ruby SchemeSmalltalk Snit Tcl VBScript Yoix etcetc etc etc…
  27. 27. Dynamic languages•  Dynamic languages are hot today because–  They are easy to use–  Have no explicit compile stage–  Have good code readability–  Allow short development time for small projects–  Performance is good enough
  28. 28. Trendy Dynamic Languages
  29. 29. Trendy Dynamic Languages
  30. 30. Trendy Dynamic Languages
  31. 31. Trendy Dynamic Languages
  32. 32. Trendy Dynamic LanguagesAlready on top of the JVM
  33. 33. …and of courseV8, Futhark, Carakan, SpiderMonkey,JägerMonkey, *Monkey, Nitro, Rhino,Nashorn, etc etc
  34. 34. Putting yourlanguage on top ofthe JVM
  35. 35. Why?•  You get so much for free!–  Automatic memory management–  State of the art JIT optimizations–  Native threading capability–  Hybridization (javax.scripting, JSR-223)–  Extending Java–  Man decades of high tech
  36. 36. Why?0100000200000300000400000500000Code basesLines
  37. 37. Why?0100000200000300000400000500000Code basesLinesIf it were all about code complexity – TOTALLY WORTH IT!
  38. 38. “All problems in computer science can be solvedby another level of indirection”- David Wheeler
  39. 39. Sounds good – implement it!•  Just serve up some bytecode•  People have been doing it since 1996
  40. 40. They have been doing it a lot,actually…FantomFortressBeanShellJaskellANTLRJudoScriptABCLErjangX10jdartjgoNiceGosuJacl
  41. 41. “All problems in computer science can be solvedby another level of indirection”- David Wheeler
  42. 42. “All problems in computer science can be solvedby another level of indirection”- David Wheeler“Except for the problem of too many layers ofindirection”- Kevlin Henney
  43. 43. So why is it hard?
  44. 44. So why is it hard?•  “Java bytecode”–  Notice the “Java”•  There are “classes”, “methods”, sizelimitations, strong types•  Languages can be much more dynamic thanJava–  Different linkage–  Loose types
  45. 45. So why is it hard?•  Different levels of “hard”•  Square peg, round hole or round peg, ovalhole•  Scala is a fairly good fit•  Ruby or JavaScript are (at least at firstglance) pretty lousy ones
  46. 46. Not every language hasexactly 5 strong typesint, float, long, double, Object
  47. 47. Not every language hasexactly 5 strong typesint sum(int a, int b) {return a + b;}int, float, long, double, Object
  48. 48. Not every language hasexactly 5 strong typesint, float, long, double, Objectiload_1iload_2iaddireturn
  49. 49. Not every language hasexactly 5 strong typesint, float, long, double, Objectfunction sum(a, b) {return a + b;}
  50. 50. Not every language hasexactly 5 strong typesint, float, long, double, Object????????????
  51. 51. Not every language hasexactly 5 strong typesint, float, long, double, Object????????????
  52. 52. Also: It is hard toswap out codewith other code
  53. 53. Also: It is hard toswap out codewith other code
  54. 54. Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?
  55. 55. Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?•  Passive–  Just wait–  JIT is getting better all the time, GC is gettingbetter all the time
  56. 56. Applicability and Performance•  The extra layer also costs us performance•  How can we work around it?•  Passive–  Just wait–  JIT is getting better all the time, GC is gettingbetter all the time•  Active–  Punch through the indirection layer–  There are tools these days
  57. 57. Punch through the indirectionlayerinvokedynamic is my ice pick
  58. 58. Invokedynamic•  Breaks the constraints of Java calls andlinkage•  Can implement calls that act like functionpointers•  More general: can implement custom dataaccess•  Makes it possible to efficiently swap out code
  59. 59. The whole point:The JVM canoptimize this!
  60. 60. The NashornProject(a Rhino for 2013)
  61. 61. Rationale•  Proof of concept: invokedynamic•  Does it provide all required functionality?•  Does it perform?•  Back in late 2010:–  We must become the ultimate invokedynamicconsumer and find out–  Cross communication with other teams
  62. 62. Rationale – JavaScript?•  Extremely dynamic–  All (well, most) getters, setters, calls have to beinvokedynamics•  Rhino is slow and old•  JSR-223–  Should make it easy to provide POC apps forNashorn
  63. 63. Full ECMAScript Compliance
  64. 64. Full ECMAScript Compliance
  65. 65. Performancerhino 0 2000 4000 6000 8000 10000 12000 rhino nashorn
  66. 66. Performancerhino 0 2000 4000 6000 8000 10000 12000 rhino nashorn
  67. 67. Further POC: node.jar•  A node.js implmentation in only Java andJavaScript–  Forked the original node.js – threw out all nativecode–  Async I/O implemented with Grizzly•  Deploys fine on the ARM JVM on RaspberryPI•  Might just as easy be a Java EE cloudoffering
  68. 68. Nashorn already in OpenJDK 8Now: more Nashorn & JVM performanceenhancementsNow: more powerful hybrid proof ofconcepts, e.g. node.jar, JavaFX
  69. 69. Contribute!1.  Ask the community to contributefunctionality, testing, performance [analysis],bug fixes, library optimizations, browsersimulation frameworks, kick-ass hybrid Javasolutions. JVM optimizations2.  …3.  PROFIT!blogs.oracle.com/nashornnashorn-dev@openjdk.java.net
  70. 70. The Da VinciMachine (MLVM)
  71. 71. Can we do better than the icepick?Reshape the hole!
  72. 72. Let’s continue building our“future VM”•  An open source incubator forJVM futures•  Contains code fragments(patches)•  Migration to OpenJDK requires–  A standard–  A feature release planmlvm-dev@openjdk.java.net
  73. 73. It’s more than justinvokedynamic•  Unified type systems•  Pluggable frontends, “bytecode 2.0”•  Tail calls•  (delimited) Continuations / Coroutines•  Tuple types or C-style structs•  Tagged values•  Arrays 2.0•  …
  74. 74. Da Vinci Machine Patches
  75. 75. It’s not just invokedynamicThe JVM is evolving to become themulti-language runtime
  76. 76. Danke![Hopefully, I’ll see you again at theNashorn / invokedynamic deep dive 16.45 thisafternoon]@lagergren

×