SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Dart != JavaScript
       Christian Grobmeier
     http://www.grobmeier.de
            @grobmeier
Was ist falsch
an 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 Browser
ist 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'            //   false
0 == ''              //   true
0 == '0'             //   true
false == 'false'     //   false
false == '0'         //   true




#9
false == undefined   //   false
false == null        //   false
null == undefined    //   true
' trn ' == 0      //   true
Darwin wusste es.



#10
Verkaufs-
argumente
Native VM


Dart Source

                           JavaScript
                 dart2js
                            Engine




              Überall.
Pub
Nix neues.
Viele Libs.
Isolates.
Serverseitig.
JS -> Dart
Roadcrew.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="otherPage">
   <h1>Other Page</h1>
   <a href="#tablePage">Table</a>
</div>
function Roadcrew() {    JavaScript
   // Constructor
}

Roadcrew.prototype = {
   // Prototyp
};

Roadcrew.prototype.act = function () {
   // Function




Prototype
};

Roadcrew.another = function () {
   // Static Function
};
class RoadcrewController {
  var pages;
                              Dart
    RoadcrewController() {
       // Constructor
    }

    void act(e) {
       // Method




              Class
    }

    void static another() {
      // Static method
    }
}
JavaScript

 Properties kopieren
 Framework extend


Vererbung
Dart
class RoadcrewController
   extends C {
   ...
}

class C {

Vererbung
}
   ...
Dart
class A implements B {
    ...
}

abstract class B {


Interfaces
   ...
}
JavaScript
function Roadcrew() {
    test = „blub“;
    var xyz = „bla“;
}

var act = function () {

Namespace
 console.log(test);
};
Dart
library Roadcrew;

import 'dart:html';

part ,RoadcrewController.dart';
part 'RoadcrewInterceptor.dart';



Namespace
part 'RoadcrewException.dart';
JavaScript
var myobj = (function() {
  var name = „CG“;
  return {
    getName = function() {
      return name;
    }


    Privacy
  }
}());
Dart

class Roadcrew {
  var _name = „CG“;
  _getTest() => name;
}



    Privacy
JavaScript


var test = „Christian“;
test = true;
test = 10.32;



      Types
Dart

class Roadcrew {
  String _name = „CG“;
  String _getTest() => name;
  List<DivElement> pages;
}


      Types
JavaScript
function RcErr(m,c,r){}

RcErr.prototype = new Error();
RcErr.prototype.constructor = RcErr;

try {
  interceptor(d, data);


Exception
} catch (error) {
   ...
}
Dart
class RcEx {
  String msg = "An error...";
  int c;
  RcEx(this.msg, [this.c = 1] );
}

try {


Exception
  interceptors[pageId].act(d);
} on RcEx catch(e) { }
JavaScript


pages = $('.page');
page = $('#myPage');



     DOM
Dart

pages = queryAll('.page');
page = query('#myPage');




     DOM
JavaScript

$("a").live(
  'click',
  $.proxy(this, 'goto'));


     DOM
Dart

queryAll('a').forEach((el) {
  el.on.click.add((e) {
    goto(e);
  });


     DOM
});
Batterien
beigelegt
import 'dart:isolate';            Dart
echo() {
  port.receive((msg, reply) {
    reply.send('I received: $msg');
  });
}

main() {
  var sendPort = spawnFunction(echo);




     Isolates
  sendPort.call('Hello').then((reply) {
    print(reply);
  });
}
Mehr?
          Dart

  I/O
 JSON
Mirrors
Logging
   ...
Wo steht Dart?
 Diskussion
Danke!

  Christian Grobmeier
http://www.grobmeier.de
       @grobmeier
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)

Weitere ähnliche Inhalte

Was ist angesagt?

ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDEJun Ho Lee
 
jQuery for designers
jQuery for designersjQuery for designers
jQuery for designersJohan Ronsse
 
Java Script - Object-Oriented Programming
Java Script - Object-Oriented ProgrammingJava Script - Object-Oriented Programming
Java Script - Object-Oriented Programmingintive
 
用 Javascript 實現你的想像
用 Javascript 實現你的想像用 Javascript 實現你的想像
用 Javascript 實現你的想像Anna Su
 
Collection pipeline par Mathieu Godart
Collection pipeline par  Mathieu GodartCollection pipeline par  Mathieu Godart
Collection pipeline par Mathieu GodartCocoaHeads France
 
JavaScript Assíncrono
JavaScript AssíncronoJavaScript Assíncrono
JavaScript AssíncronoNatã Barbosa
 
JS programowanie obiektowe
JS  programowanie obiektoweJS  programowanie obiektowe
JS programowanie obiektowePiotr Czajkowski
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebSebastian Springer
 
Clase 7 el modelo
Clase 7  el modeloClase 7  el modelo
Clase 7 el modelohydras_cs
 
Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017Taller Negócio Digitais
 
Introduction to Service Worker
Introduction to Service WorkerIntroduction to Service Worker
Introduction to Service WorkerShogo Sensui
 
Working With Ajax Frameworks
Working With Ajax FrameworksWorking With Ajax Frameworks
Working With Ajax FrameworksJonathan Snook
 
GRUNT - The JavaScript Task Runner
GRUNT - The JavaScript Task RunnerGRUNT - The JavaScript Task Runner
GRUNT - The JavaScript Task RunnerLarry Nung
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 

Was ist angesagt? (20)

ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDE
 
jQuery for designers
jQuery for designersjQuery for designers
jQuery for designers
 
Java Script - Object-Oriented Programming
Java Script - Object-Oriented ProgrammingJava Script - Object-Oriented Programming
Java Script - Object-Oriented Programming
 
用 Javascript 實現你的想像
用 Javascript 實現你的想像用 Javascript 實現你的想像
用 Javascript 實現你的想像
 
jQuery PLUGIN
jQuery PLUGINjQuery PLUGIN
jQuery PLUGIN
 
Jquery ui, ajax
Jquery ui, ajaxJquery ui, ajax
Jquery ui, ajax
 
Web App Mvc
Web App MvcWeb App Mvc
Web App Mvc
 
Collection pipeline par Mathieu Godart
Collection pipeline par  Mathieu GodartCollection pipeline par  Mathieu Godart
Collection pipeline par Mathieu Godart
 
詳説WebAssembly
詳説WebAssembly詳説WebAssembly
詳説WebAssembly
 
JavaScript Assíncrono
JavaScript AssíncronoJavaScript Assíncrono
JavaScript Assíncrono
 
JS programowanie obiektowe
JS  programowanie obiektoweJS  programowanie obiektowe
JS programowanie obiektowe
 
Prototype UI
Prototype UIPrototype UI
Prototype UI
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im Produktivbetrieb
 
Clase 7 el modelo
Clase 7  el modeloClase 7  el modelo
Clase 7 el modelo
 
Primeiros passos-com-docker
Primeiros passos-com-dockerPrimeiros passos-com-docker
Primeiros passos-com-docker
 
Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017
 
Introduction to Service Worker
Introduction to Service WorkerIntroduction to Service Worker
Introduction to Service Worker
 
Working With Ajax Frameworks
Working With Ajax FrameworksWorking With Ajax Frameworks
Working With Ajax Frameworks
 
GRUNT - The JavaScript Task Runner
GRUNT - The JavaScript Task RunnerGRUNT - The JavaScript Task Runner
GRUNT - The JavaScript Task Runner
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 

Mehr von Christian Grobmeier

Mehr von Christian Grobmeier (6)

The "Why Should You Talk" Talk
The "Why Should You Talk" TalkThe "Why Should You Talk" Talk
The "Why Should You Talk" Talk
 
Zen Programming
Zen ProgrammingZen Programming
Zen Programming
 
Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014Go Mobile with Apache Cordova, Zagreb 2014
Go Mobile with Apache Cordova, Zagreb 2014
 
Apps with Apache Cordova and Phonegap
Apps with Apache Cordova and PhonegapApps with Apache Cordova and Phonegap
Apps with Apache Cordova and Phonegap
 
Dart @ JUG Saxony
Dart @ JUG SaxonyDart @ JUG Saxony
Dart @ JUG Saxony
 
World of Logging
World of LoggingWorld of Logging
World of Logging
 

Dart != JavaScript

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n