Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dart, Je m'y mets ou je m'y mets pas ?

Dart, Je m'y mets ou je m'y mets pas ?

Dart, le nouveau langage pour le Web de Google. Doit-on s'y intéresser ? Doit-on suivre son évolution ?

Julien Vey

May 22, 2013
Tweet

More Decks by Julien Vey

Other Decks in Programming

Transcript

  1. classes, typage optionnel import 'dart:math'; class Point { num x,

    y; Point(this.x, this.y); num distanceTo(Point other) { var dx = x - other.x; var dy = y - other.y; return sqrt(dx * dx + dy * dy); } } main() { var a = new Point(2, 2); var b = new Point(4, 5); print('distance from a to b :${a.distanceTo(b)}'); }
  2. fonctions [0, 1, 2, 3].where((n) {return n.isEven;}).forEach((n) {print (n);}); [0,

    1, 2, 3].where((n) => n.isEven).forEach((n) => print (n)); [0, 1, 2, 3].where((n) => n.isEven).forEach(print);
  3. mixins class Musical { final Instrument instrument; Musical(this.instrument); } class

    Aggressive { final String aggressionLevel; Aggressive(this.aggressionLevel); } class Demented { final disorder; Demented(this.disorder); } class Maestro extends Person with Musical, Aggressive, Demented { Maestro(name, disorder, degree, instrument) : Demented(disorder), Aggressive(degree), Musical(instrument), super(name); }
  4. dart:html Element elem1 = query('#an-id'); List<Element> elems2 = queryAll('input[type="text"]'); query('#example').href

    = 'dartlang.org'; var elem = new ParagraphElement(); elem.text = 'Creating is easy!'; query('#inputs').nodes.add(elem);
  5. dart:io import 'dart:io'; main() { dartHandler(HttpRequest request) { print('New request');

    request.response.write('Dart is optionally typed'); request.response.close(); }; HttpServer.bind('127.0.0.1', 8888).then((HttpServer server) { server.listen((request) { print("got request"); if (request.uri.path == '/languages/dart') { dartHandler(request); } else { request.response.write('Not found'); request.response.statusCode = HttpStatus.NOT_FOUND; request.response.close(); } }); }); }
  6. dart:isolate import 'dart:isolate'; echo() { port.receive((msg, reply) { reply.send('I received:

    $msg'); }); } main() { var sendPort = spawnFunction(echo); sendPort.call('Hello from main').then((reply) { print(reply); }); }
  7. web components <element name="x-click-counter" constructor="CounterComponent" extends="div"> <template> <button on-click="increment()">Click me</button>

    <span>(click count: {{count}})</span> </template> <script type="application/dart"> import 'package:web_ui/web_ui.dart'; class CounterComponent extends WebComponent { int count = 0; void increment(e) { count++; } } </script> </element> ... <div is="x-click-counter"></div>
  8. model-driven-view <html><body> <div> <button on-click="increment()">Click me</button> <span>(click count: {{count}})</span> </div>

    <script type="application/dart"> int count = 0; void increment(e) { count++; } main() {} </script> </body></html>
  9. model-driven-view <html><body> <div> <button on-click="increment()">Click me</button> <span>(click count: {{count}})</span> </div>

    <script type="application/dart"> int count = 0; void increment(e) { count++; } main() {} </script> </body></html> <template instantiate="if str1 == str2"> <div>They match!</div> </template>
  10. model-driven-view <html><body> <div> <button on-click="increment()">Click me</button> <span>(click count: {{count}})</span> </div>

    <script type="application/dart"> int count = 0; void increment(e) { count++; } main() {} </script> </body></html> <template instantiate="if str1 == str2"> <div>They match!</div> </template> <template iterate='fruit in results'> <li>{{fruit}}</li> </template>
  11. pub name: sampleproject version: 1.0.0 description: sample dart demo dependencies:

    route: 0.4.5 mustache: ‘>=0.1.5’ orientdb: git: git://github.com/jyuro/orientdb.git dev_dependencies: unittest: any