DukeScript

5,799 views

Published on

DukeScript is a new way of writing JavaScript applications that lets you take advantage of a powerful binding model to connect to Java code running in a local JVM.

Published in: Technology

DukeScript

  1. 1. DUKESCRIPT Puts the Java in JavaScript
  2. 2. ProblemI
  3. 3. ProblemII
  4. 4. Chuck Norris can instantiate abstract classes can run Java on iPad and Android without Jailbreak! uses generics since Java 1.0 overrides final methods Chuck Norris on the set of "The Delta Force" (1986), Copyright Yoni S.Hamenahem
  5. 5. bck2brwsr vs HotSpot „World of Warcraft Commercial" Copyright ©Blizzard Entertainment
  6. 6. The Solution "The Way of the Dragon" Copyright © 20th Century Fox Home Entertainment / Bryanston Distributing / CBS/Fox / Cinema Classics
  7. 7. BCK2BRWSR
  8. 8. DESIGNER VS DEVELOPER
  9. 9. DESIGNER VS DEVELOPER index.html <html> <button id="hello"> Say Hello!</button> </html> ! App.java @Model(className="Person" , properties={ @Property(name = "selectedName", type=String.class), }) static class PersonModel{ ... }
  10. 10. DUKESCRIPT Puts the Java in JavaScript
  11. 11. alternatively use bck2brwsr
  12. 12. KNOCKOUT4J
  13. 13. @Model(className="Person", properties={ @Property(name = "firstName", type=String.class), @Property(name = "lastName", type=String.class) @Property(name = "addresses", type=Address.class, array = true) }) static class PersonModel { http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/ package-summary.html
  14. 14. @Model(className="Address", properties={ @Property(name = "street", type=String.class), @Property(name = "town", type=String.class) }) static class AddressModel { } http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/ package-summary.html
  15. 15. @ComputedProperty static String fullName(String firstName, String lastName) { return firstName + " " + lastName; } http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/ package-summary.html
  16. 16. <span data-bind="text: fullName"> <div data-bind="foreach: addresses"> Lives in <span data-bind="text: town"/> </div> http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/ package-summary.html
  17. 17. @ComputedProperty static String fullName(String firstName, String lastName) { return firstName + " " + lastName; } http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/ package-summary.html
  18. 18. CANVAS 0.5.2 https://github.com/eppleton/canvas
  19. 19. ! ≈! HTML5 CANVAS! CANVAS API
  20. 20. CANVAS API GraphicsContext2D gc = HTML5Graphics.getOrCreate("canvas"); gc.setLineWidth(30); gc.setFont("24px Helvetica"); gc.fillText("Hello World!", 175, 200); gc.setFillStyle(new Color("rgba(0, 0, 255, 0.5)“)); gc.strokeRect(75, 100, 200, 200); gc.fillRect(325, 100, 200, 200);
  21. 21. JAVAFX WITH CANVAS API IN BCK2BRWSR http://xelfi.cz/fishsim/
  22. 22. FXGAMES https://github.com/eppleton/FXGameEngine
  23. 23. DUKESCRIPT ! ! ! UNIVERSITY
  24. 24. Task 1 Create your own application in Java that renders through HTML.! Write your own model and display and animate it. mvn archetype:generate -DarchetypeGroupId=org.apidesign.html -DarchetypeArtifactId=knockout4j-archetype -DarchetypeVersion=0.7.5
  25. 25. Task 2 Create your own application using the Canvas API mvn archetype:generate -DarchetypeGroupId=org.apidesign.canvas -DarchetypeArtifactId=canvas-archetype -DarchetypeVersion=0.5.2
  26. 26. Task 3 Use JSON/REST to communicate with a server API Doc: http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/OnReceive.html Demo: http://dew.apidesign.org/dew/#7138581 See also: http://bits.netbeans.org/html4j/0.7.5/net/java/html/json/doc-files/websockets.html
  27. 27. HOW CAN WE IMPROVE IT?
  28. 28. We want you for DukeScript http://bits.netbeans.org/html4j/0.7.5/ and https://github.com/eppleton/canvas Thank you! ! @monacotoni

×