dart jug 2013

Post on 24-Jun-2015

493 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

DartOne language to rule them all …

Sébastien Deleuze - @sdeleuze

Worldline  

Lyon  

!Architecte logiciel (qui code)  Innovation Labs  

!Projets Open Sources

Sébastien Deleuze

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 ?

Une plateforme Open Source

Langage

Outillage

Machine virtuelle

Documentation

API

Frameworkweb

Compilateur Dart / Javascript Dépôt de paquets

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

Environnements d’exécution

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

Environnements d’exécution

Chrome (VM Dart)

Serveur

Autres navigateurs(VM Javascript)

Android

PaaS ??

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)}');  }

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?';  }

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

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

Un langage facile à apprendre

I am watching you !

LangageMais aussi

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

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);  !}

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 !');   });  }

Web components

Performance

0

175

350

525

700

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

Sans  snapshotAvec  snapshot

Démarrage

Performance

0

50

100

150

200

250

DeltaBlue Richards Tracer

Javascriptdart2jsDart  VMJava

Exécution

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;

PerformanceTaille javascript généré

0

45

90

135

180

Taille  de  l'applicaJon  Todo  (Ko)

AngularJSDartAngularJS  +  jQuery

OutillageIDE : Dart Editor

OutillageIDE : pas obligé d’utiliser Eclipse

Spark

Support de Dart dans Idea Intellijet WebStorm

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

Outillagepub.dartlang.org

Demos

• Projet Dart « Fullstack»  

• Three.dart

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 ...

top related