dart jug 2013

27
Dart One language to rule them all … Sébastien Deleuze - @sdeleuze

Upload: sebastien-deleuze

Post on 24-Jun-2015

493 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Dart JUG 2013

DartOne language to rule them all …

Sébastien Deleuze - @sdeleuze

Page 2: Dart JUG 2013

Worldline  

Lyon  

!Architecte logiciel (qui code)  Innovation Labs  

!Projets Open Sources

Sébastien Deleuze

Page 3: Dart JUG 2013

Un langage structuré et flexible pour les développements Web (mais pas que)  !Destiné aux navigateurs modernes  !Pour améliorer lamaintenabilité et l’efficacité de nos développements

Dart, c’est quoi exactement ?

Page 4: Dart JUG 2013

Une plateforme Open Source

Langage

Outillage

Machine virtuelle

Documentation

API

Frameworkweb

Compilateur Dart / Javascript Dépôt de paquets

Page 5: Dart JUG 2013

Comparaison= Orienté Objet = Facile à apprendre = Performance de la JVM != Dette technologique

= Les fonctions sont «first class citizens» = API asynchrone != Dart est fourni «battery-included»

Modèle de thread Gestion de la concurence

Page 6: Dart JUG 2013

Environnements d’exécution

Chrome (VM Dart) Autres navigateurs(dart2js + VM Javascript)

Page 7: Dart JUG 2013

Environnements d’exécution

Chrome (VM Dart)

Serveur

Autres navigateurs(VM Javascript)

Android

PaaS ??

Page 8: Dart JUG 2013

LangageOrienté objet, typage optionnel et interpolation de chaines

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, 3);   var b = new Point(3, 4);   print('distance from a to b = ${a.distanceTo(b)}');  }

Page 9: Dart JUG 2013

LangageInterfaces implicites

class Person {   final _name;   Person(this._name);   String greet(who) => 'Hello, $who. I am $_name.';  }  !class Bro implements Person {   String greet(who) => 'Hi $who. What’s up?';  }

Page 10: Dart JUG 2013

LangageFonctions

// Display 0 2 4 6 in the console main() { [0, 1, 2, 3, 4, 5, 6].where((n) => n.isEven).forEach(print); }

// Display 0 2 4 6 in the console main() { var array = [0, 1, 2, 3, 4, 5, 6]; for(var n in array) { if(n.isEven) { print(n); } } }

Version longue

Version courte

Page 11: Dart JUG 2013

LangageParamètres optionnels et valeurs par défaut

String say(String from, String msg, [String channel='email']) {   // ...  }  !main() {   say('Bob', 'Howdy');   say('Bob', 'Howdy', 'smoke signal');  }

enableFlags({bool bold: false, bool hidden: false}) {   // ...  }  !main() {   enableFlags();   enableFlags(bold: true);   enableFlags(bold: true, hidden: false);  }

Paramètres nommés et valeurs par défaut

Page 12: Dart JUG 2013

Un langage facile à apprendre

I am watching you !

Page 13: Dart JUG 2013

LangageMais aussi

- Constructeurs nommés - Mixins - Modèle de thread léger proche d’Erlang - Métadatas - Generics - Reflection

Page 14: Dart JUG 2013

APIdart:html

import 'dart:html';  !main() {  ! var message = query('#msg');  ! var b = new ButtonElement()   ..classes.add('important')   ..text = 'Bro Code'   ..onClick.listen((e) => message.text = '''A bro does not dare/challenge another bro to do anything they wouldn’t try them self''');  ! document.body.children.add(b);  !}

Page 15: Dart JUG 2013

APIdart:io

import 'dart:io';  !main() {   HttpServer.bind('127.0.0.1', 8080).then((server) {   server.listen((HttpRequest request) {   request.response   ..write('A bro cannot give another bro a Teddy bear')   ..close();   });   print('web server started !');   });  }

Page 16: Dart JUG 2013

Web components

Page 18: Dart JUG 2013

Performance

0

175

350

525

700

Temps  de  chargement  d'un  programme  de  55000  lignes  (ms)

Sans  snapshotAvec  snapshot

Démarrage

Page 19: Dart JUG 2013

Performance

0

50

100

150

200

250

DeltaBlue Richards Tracer

Javascriptdart2jsDart  VMJava

Exécution

Page 20: Dart JUG 2013

PerformanceSingle instruction, multiple data (SIMD)

1.0 5.0 6.0

2.0 10.0 12.0

3.0 12.0 15.0

4.0 20.0 24.0

+ =

var a = new Float32x4(1.0, 2.0, 3.0, 4.0);var b = new Float32x4(5.0, 10.0, 15.0, 20.0);var c = a + b;

Page 21: Dart JUG 2013

PerformanceTaille javascript généré

0

45

90

135

180

Taille  de  l'applicaJon  Todo  (Ko)

AngularJSDartAngularJS  +  jQuery

Page 22: Dart JUG 2013

OutillageIDE : Dart Editor

Page 23: Dart JUG 2013

OutillageIDE : pas obligé d’utiliser Eclipse

Spark

Support de Dart dans Idea Intellijet WebStorm

Page 24: Dart JUG 2013

Outillagepub

name: myprojectversion: 1.1.0  description: Sample application  author: Sébastien Deleuze  homepage: http://jyuro.org  documentation: http://jyuro.org/doc  dependencies:   route: 0.4.5 mustache : '>=0.1.5' mylib:       git: git://github.com/jyuro/mylib.git  dev_dependencies:   unittest: any

Page 25: Dart JUG 2013

Outillagepub.dartlang.org

Page 26: Dart JUG 2013

Demos

• Projet Dart « Fullstack»  

• Three.dart

Page 27: Dart JUG 2013

Conclusion

Sébastien Deleuze - @sdeleuze

Quelques liens :   - http://news.dartlang.org   - http://gplus.to/dartlangfr - http://try.dartlang.org/ - https://github.com/sdeleuze/polymer-dart-blog

Dart 1.0 est sorti, testez-le ...