Un linguaggio intuitivo e familiare ed un vasto insieme di librerie e strumenti di sviluppo: questo è Dart, la nuova piattaforma "batteries included" orientata allo sviluppo di web application scalabili e compatibili con i maggiori browser moderni, desktop e mobile, sviluppata in Google. Al Codemotion Milano 2014 vedremo una panoramica del linguaggio e svilupperemo insieme una web app di esempio per vedere più da vicino tutti i vantaggi di Dart rispetto alle piattaforme tradizionali.
Human Factors of XR: Using Human Factors to Design XR Systems
Join the Dart Side of Web Development - Giovanni Laquidara - Codemotion Milan 2014
1. MILAN november 28th/29th 2014
Giovanni Laquidara
Join the Dart Side of Web Development.
glaquidara@gmail.com - Google Developer Group Roma
2. MILAN november 28th/29th 2014 – Speaker's name
dest templates
Backbone Marionette
Modernizr
Backbone
require.js
jQuery
moment.js
PhantomJS
Jasmine
Docs
Docs
Docs
Docs
Docs
Docs
Docs
Docs
Docs
3. MILAN november 28th/29th 2014 – Speaker's name
● Language
● Libraries
● Tools
● Compilation to Javascript
4. MILAN november 28th/29th 2014 – Speaker's name
Dart is open source
● BSD-style license
● dart.googlecode.com
● GitHub mirror
● Contributing guide
● ECMA Standard (TC52)
● Production ready (1.8)
7. MILAN november 28th/29th 2014 – Speaker's name
import 'dart:math' show Random; // Import a class from a library.
void main() { // The app starts executing here.
print(new Dice(n: 12).roll()); // Print a new object's value.
}
class Dice { // Define a class.
static Random shaker = new Random(); // Define a class variable.
int sides, value; // Define instance variables.
String toString() => '$value'; // Define a method using shorthand
syntax.
Dice({int n: 6}) { // Define a constructor.
if (4 <= n && n <= 20) {
sides = n;
} else {
throw new ArgumentError(/* */); // Support for errors and exceptions.
}
}
int roll() { // Define an instance method.
return value = shaker.nextInt(sides) + 1; // Get a random number.
}
}
9. MILAN november 28th/29th 2014 class H –u Spgeak er's{ name
num _strength;
num get strength {
// some code
return this._strength;
}
set strength(num value) {
// do something with value;
this._strength = value;
}
}
10. MILAN november 28th/29th 2014 class H –u Spgeak er's{ name
num _strength;
Hug(strength) {
this._strength = strength;
}
Hug.light(strength) {
this._strength = 0;
}
}
11. MILAN november 28th/29th 2014 class H –u Spgeak er's{ name
num _strength;
Hug(this._strength);
}
12. MILAN november 28th/29th 2014 class H –u Spgeak er's{ name
num _strength;
Hug(this._strength);
Hug operator +(Hug other) {
return new Hug(strength +
other.strength);
}
}
13. MILAN november 28th/29th 2014 – Speaker's name
var button = new ButtonElement();
button.id = 'fancy';
button.text = 'Click Point';
button.classes.add('important');
button.onClick.listen((e) => addTopHat());
parentElement.children.add(button);
14. MILAN november 28th/29th 2014 – Speaker's name
var button = new ButtonElement();
..id = 'fancy';
..text = 'Click Point';
..classes.add(‘important');
..onClick.listen((e) => addTopHat());
parentElement.children.add(button);
15. MILAN november 28th/29th 2014 – Speaker's name
Missing getter?
"Coffee".missing // ??
Class 'String' has no instance getter 'missing'.
NoSuchMethodError : method not found: 'missing' Receiver:
"Coffee"
Arguments: []
16. MILAN november 28th/29th 2014 – Speaker's name
String compared to
number?
“2” > 1 // ??
Unhandled exception:
Class 'String' has no instance method '>'.
NoSuchMethodError : method not found: '>'
Receiver: "2"
Arguments: [1]
17. MILAN november 28th/29th 2014 – Speaker's name
Lexical Closures?
var talk = (s) => print(s);
talk("Hi there");
18. MILAN november 28th/29th 2014 – Speaker's name
void main() {
String name = "Giovanni Laquidara";
print(initials(name));
}
String initials(String name) {
StringBuffer retValue = new StringBuffer();
name.split(" ").forEach( (String part ) {
retValue.write(part[0] + '.');
});
return retValue.toString();
}
19. MILAN november 28th/29th 2014 – Speaker's name
main() {
var name = "Giovanni Laquidara";
print(initials(name));
}
initials(name) {
var retValue = new StringBuffer();
name.split(" ").forEach( ( part ) {
retValue.write(part[0] + '.');
});
return retValue.toString();
}
21. MILAN november 28th/29th 2014 – Speaker's name
import 'dart:async' show Future, Completer;
void main() {
loadNews().then( (news) {
//Do something with news
});
print("Just print!");
}
Future loadNews() {
Completer completer = new Completer();
//Insert very slow process here
completer.complete();
return completer.future;
}
22. MILAN november 28th/29th 2014 – Speaker's name
import 'dart:io';
main() {
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 4040)
.then((HttpServer server) {
print('listening on localhost, port $
{server.port}');
server.listen((HttpRequest request) {
request.response.write('Hello, world!');
request.response.close();
});
}).catchError((e) => print(e.toString()));
}
25. MILAN november 28th/29th 2014 – Speaker's name
pubspec.yaml
name: gdghunt
description: A application using google play game services
version: 0.1.0
author: Giovanni Laquidara
dependencies:
googleapis: any
googleapis_auth: any
browser: any
core_elements: ">=0.2.0 <0.3.0"
polymer: ">=0.12.0 <0.13.0"
paper_elements: ">=0.1.0 <0.2.0"
26. MILAN november 28th/29th 2014 – Speaker's name
The web is full of links, yet web dev has no linker
imports
main Library
calls
foo bar boo
baz
Tree shaking
dart2js
main foo bar
27. MILAN november 28th/29th 2014 – Speaker's name
(bigger is better)
https://www.dartlang.org/performance
32. MILAN november 28th/29th 2014 – Speaker's name
Designed for Dart: use classes, annotations, and more. Build apps that scale.
AngularDart brings the proven Angular philosophy of testable, succinct web development to Dart.
AngularDart embraces modern web platform features, starting with Shadow DOM and Web Components.
36. MILAN november 28th/29th 2014 – Speaker's name
Homepage: https://dartlang.org
API Reference: https://api.dartlang.org
Pub Packages: https://pub.dartlang.org
37. MILAN november 28th/29th 2014 – Speaker's name
Giovanni Laquidara
+GiovanniLaquidara
@joaolaq
joaobiriba
http://roma.gdg.io/
thanks() => new FeedBack();
getQuestions().then( (what) {
answer(what);
});