Dart != JavaScript       Christian Grobmeier     http://www.grobmeier.de            @grobmeier
Was ist falschan JavaScript?
JavaScript „false“:   false, 0, „“, undefined, null#1
Batterien selbst besorgen. jQuery et al ist    Pflicht.#2
Segen oder Fluch? Keine Typen#3
1000 und 1 Möglichkeit Vererbung#4
Patterns helfen: Namespace#5
Jeder Browserist ein Individuum.#6
Nicht nett.var a1 = new Array(1,2,3,4,5);    var a2 = new Array(5);#7
Einer für alle.if( a === null || a === undefined)#8
Fallstricke. == 0            //   false0 ==               //   true0 == 0             //   truefalse == false     //   fal...
Darwin wusste es.#10
Verkaufs-argumente
Native VMDart Source                           JavaScript                 dart2js                            Engine       ...
Pub
Nix neues.
Viele Libs.
Isolates.
Serverseitig.
JS -> DartRoadcrew.js(https://github.com/grobmeier/Roadcrew.js
Use Case<div class="page" id="tablePage">   <h1>Table Page</h1>   <a href="#otherPage">Other</a></div><div class="page" id...
function Roadcrew() {    JavaScript   // Constructor}Roadcrew.prototype = {   // Prototyp};Roadcrew.prototype.act = functi...
class RoadcrewController {  var pages;                              Dart    RoadcrewController() {       // Constructor   ...
JavaScript Properties kopieren Framework extendVererbung
Dartclass RoadcrewController   extends C {   ...}class C {Vererbung}   ...
Dartclass A implements B {    ...}abstract class B {Interfaces   ...}
JavaScriptfunction Roadcrew() {    test = „blub“;    var xyz = „bla“;}var act = function () {Namespace console.log(test);};
Dartlibrary Roadcrew;import dart:html;part ,RoadcrewController.dart;part RoadcrewInterceptor.dart;Namespacepart RoadcrewEx...
JavaScriptvar myobj = (function() {  var name = „CG“;  return {    getName = function() {      return name;    }    Privac...
Dartclass Roadcrew {  var _name = „CG“;  _getTest() => name;}    Privacy
JavaScriptvar test = „Christian“;test = true;test = 10.32;      Types
Dartclass Roadcrew {  String _name = „CG“;  String _getTest() => name;  List<DivElement> pages;}      Types
JavaScriptfunction RcErr(m,c,r){}RcErr.prototype = new Error();RcErr.prototype.constructor = RcErr;try {  interceptor(d, d...
Dartclass RcEx {  String msg = "An error...";  int c;  RcEx(this.msg, [this.c = 1] );}try {Exception  interceptors[pageId]...
JavaScriptpages = $(.page);page = $(#myPage);     DOM
Dartpages = queryAll(.page);page = query(#myPage);     DOM
JavaScript$("a").live(  click,  $.proxy(this, goto));     DOM
DartqueryAll(a).forEach((el) {  el.on.click.add((e) {    goto(e);  });     DOM});
Batterienbeigelegt
import dart:isolate;            Dartecho() {  port.receive((msg, reply) {    reply.send(I received: $msg);  });}main() {  ...
Mehr?          Dart  I/O JSONMirrorsLogging   ...
Wo steht Dart? Diskussion
Danke!  Christian Grobmeierhttp://www.grobmeier.de       @grobmeier
Image Credits    Omikuji: Flickr (jessleecuizon)     Dollars: Flickr (401(K) 2012)        Pub: Flickr (ell brown)        D...
Dart != JavaScript
Upcoming SlideShare
Loading in …5
×

Dart != JavaScript

4,489 views

Published on

Talk about Dart (www.dartlang.org) and how it compares to JavaScript. Happened at the Java Usergroup in Stuttgart on 22.11.2012.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Dart != JavaScript

  1. 1. Dart != JavaScript Christian Grobmeier http://www.grobmeier.de @grobmeier
  2. 2. Was ist falschan JavaScript?
  3. 3. JavaScript „false“: false, 0, „“, undefined, null#1
  4. 4. Batterien selbst besorgen. jQuery et al ist Pflicht.#2
  5. 5. Segen oder Fluch? Keine Typen#3
  6. 6. 1000 und 1 Möglichkeit Vererbung#4
  7. 7. Patterns helfen: Namespace#5
  8. 8. Jeder Browserist ein Individuum.#6
  9. 9. Nicht nett.var a1 = new Array(1,2,3,4,5); var a2 = new Array(5);#7
  10. 10. Einer für alle.if( a === null || a === undefined)#8
  11. 11. Fallstricke. == 0 // false0 == // true0 == 0 // truefalse == false // falsefalse == 0 // true#9false == undefined // falsefalse == null // falsenull == undefined // true trn == 0 // true
  12. 12. Darwin wusste es.#10
  13. 13. Verkaufs-argumente
  14. 14. Native VMDart Source JavaScript dart2js Engine Überall.
  15. 15. Pub
  16. 16. Nix neues.
  17. 17. Viele Libs.
  18. 18. Isolates.
  19. 19. Serverseitig.
  20. 20. JS -> DartRoadcrew.js(https://github.com/grobmeier/Roadcrew.js
  21. 21. Use Case<div class="page" id="tablePage"> <h1>Table Page</h1> <a href="#otherPage">Other</a></div><div class="page" id="otherPage"> <h1>Other Page</h1> <a href="#tablePage">Table</a></div>
  22. 22. function Roadcrew() { JavaScript // Constructor}Roadcrew.prototype = { // Prototyp};Roadcrew.prototype.act = function () { // FunctionPrototype};Roadcrew.another = function () { // Static Function};
  23. 23. class RoadcrewController { var pages; Dart RoadcrewController() { // Constructor } void act(e) { // Method Class } void static another() { // Static method }}
  24. 24. JavaScript Properties kopieren Framework extendVererbung
  25. 25. Dartclass RoadcrewController extends C { ...}class C {Vererbung} ...
  26. 26. Dartclass A implements B { ...}abstract class B {Interfaces ...}
  27. 27. JavaScriptfunction Roadcrew() { test = „blub“; var xyz = „bla“;}var act = function () {Namespace console.log(test);};
  28. 28. Dartlibrary Roadcrew;import dart:html;part ,RoadcrewController.dart;part RoadcrewInterceptor.dart;Namespacepart RoadcrewException.dart;
  29. 29. JavaScriptvar myobj = (function() { var name = „CG“; return { getName = function() { return name; } Privacy }}());
  30. 30. Dartclass Roadcrew { var _name = „CG“; _getTest() => name;} Privacy
  31. 31. JavaScriptvar test = „Christian“;test = true;test = 10.32; Types
  32. 32. Dartclass Roadcrew { String _name = „CG“; String _getTest() => name; List<DivElement> pages;} Types
  33. 33. JavaScriptfunction RcErr(m,c,r){}RcErr.prototype = new Error();RcErr.prototype.constructor = RcErr;try { interceptor(d, data);Exception} catch (error) { ...}
  34. 34. Dartclass RcEx { String msg = "An error..."; int c; RcEx(this.msg, [this.c = 1] );}try {Exception interceptors[pageId].act(d);} on RcEx catch(e) { }
  35. 35. JavaScriptpages = $(.page);page = $(#myPage); DOM
  36. 36. Dartpages = queryAll(.page);page = query(#myPage); DOM
  37. 37. JavaScript$("a").live( click, $.proxy(this, goto)); DOM
  38. 38. DartqueryAll(a).forEach((el) { el.on.click.add((e) { goto(e); }); DOM});
  39. 39. Batterienbeigelegt
  40. 40. import dart:isolate; Dartecho() { port.receive((msg, reply) { reply.send(I received: $msg); });}main() { var sendPort = spawnFunction(echo); Isolates sendPort.call(Hello).then((reply) { print(reply); });}
  41. 41. Mehr? Dart I/O JSONMirrorsLogging ...
  42. 42. Wo steht Dart? Diskussion
  43. 43. Danke! Christian Grobmeierhttp://www.grobmeier.de @grobmeier
  44. 44. Image Credits Omikuji: Flickr (jessleecuizon) Dollars: Flickr (401(K) 2012) Pub: Flickr (ell brown) Dog: Flickr (joshme17) Package: Flickr (lemonhalf) Threads: Flickr (The Big Quack) Server: Flickr (getButterfly) School Bus: Flickr (loop_oh) Batteries: Flickr (scalespeeder)Discussing Monks: Flickr (wonderlane)

×