Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ZHGDG[7.27]GDL.3~10 Reasons You_ll Love Dart
Search
Zoom.Quiet
July 29, 2013
Technology
0
88
ZHGDG[7.27]GDL.3~10 Reasons You_ll Love Dart
ZHGDG[7.27]GDL.3
10 Reasons You_ll Love Dart Presentation
Zoom.Quiet
July 29, 2013
Tweet
Share
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
130
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
100
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
80
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
84
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
65
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
78
PyCon2014China-Zhuhai-jeff
zoomquiet
0
58
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
87
DevFest2014-Zhuhai-Polymer
zoomquiet
0
370
Other Decks in Technology
See All in Technology
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
680
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
5分でわかるDuckDB
chanyou0311
10
3.2k
ハイテク休憩
sat
PRO
2
140
なぜCodeceptJSを選んだか
goataka
0
160
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.2k
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
190
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Why Our Code Smells
bkeepers
PRO
335
57k
Building an army of robots
kneath
302
44k
Transcript
10 Reasons You're Going to Love Dart Chris Strom @eee_c
• Browser Language (primarily) • Familiar • Incorporates Lessons Learned
JavaScript • Browser Language (primarily) • Familiar • Incorporates Lessons
Learned
10+
-Alan Perlis A language that doesn't affect the way you
think about programming, is not worth knowing.
Ew... Static Typing
hostile to the open-web non-standard language
Nobody is using it…
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
say_hi(name) { return "Hi, ${name}"; } say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
say_hi(name) { return "Hi, ${name}"; } say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions
say_hi(name) { return "Hi, ${name}"; } say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions
say_hi(name) { return "Hi, ${name}"; } say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions say_hi(name) { return "Hi, ${name}"; }
say_hi("Bob"); // "Hi, Bob"
Quick Dart Primer: Functions say_hi(name) => "Hi, ${name}"; say_hi("Bob"); //
"Hi, Bob"
var say_hi = (name) => "Hi, ${name}"; say_hi("Bob"); // "Hi,
Bob" Quick Dart Primer: Anon. Functions
Oh, Ruby… I ♥ You So Much class Cookie attr_reader
:number_of_chips def initialize(num) @number_of_chips = num end end c = Cookie.new(1) c.number_of_chips => 1
Oh, Dart… I ♥ You So Much class Cookie {
var number_of_chips; Cookie(num) { number_of_chips = num; } }
Magic Instance Variables class Cookie { var number_of_chips; Cookie(num) {
number_of_chips = num; } }
Magic Instance Variables class Cookie { var number_of_chips; Cookie(this.number_of_chips); }
Magic Instance Variables class Cookie { var number_of_chips; Cookie(this.number_of_chips); }
> var cookie = new Cookie(12); > cookie.number_of_chips; // 12 > cookie.number_of_chips = 25; > cookie.number_of_chips; // 25
Magic Instance Variables class Cookie { var _calories; // ...
} > var cookie = new Cookie(); > cookie._calories; // Error! > cookie._calories = 25; // Error!
Getters and Setters class Cookie { var _calories; get calories
=> _calories / 3; set calories(v) { _calories = v; } } > var cookie = new Cookie(); > cookie.calories = 300; > cookie.calories; // 100
Optional Parameters class Cookie { var calories; Cookie({calories}) { this.calories
= calories; } } > c1 = new Cookie(calories: 300); > c2 = new Cookie();
Optional Parameters class Cookie { var calories, number_of_chips; Cookie({ this.calories,
this.number_of_chips }); } > c1 = new Cookie(calories: 300); > c1.calories; // 300
Optional Parameters class Cookie { var calories, number_of_chips; Cookie({ this.calories,
this.number_of_chips }); } > c2 = new Cookie(number_of_chips: 9); > c2.number_of_chips; // 9
Optional Parameters class Cookie { var calories, number_of_chips; Cookie({ this.calories,
this.number_of_chips: 2 }); } > c3 = new Cookie(); > c3.number_of_chips; // 2
Optional Parameters class Cookie { var calories, number_of_chips; Cookie([ this.calories,
this.number_of_chips]); } > c1 = new Cookie(120, 9); > c2 = new Cookie(120); > c3 = new Cookie();
Method Cascades cookie ..mix_it() ..stir_it() ..bake_it() ..eat_it();
Method Cascades cookie ..calories = 120 ..number_of_chips = 12 ..bake_time
= 30 ..deliciousness = 42;
Method Cascades bg.style ..position = 'absolute' ..top = '0px' ..left
= '0px' ..width = "${doc.offsetWidth}px" ..height = "${doc.clientHeight}px" ..backgroundColor = 'black' ..opacity = '0.8' ..zIndex = '1000';
Unit Tests test_create() { group("new DBs", () { setUp(removeFixtures); tearDown(removeFixtures);
test("creates a new DB", () {/*…*/}); }); }
Unit Tests test_create() { group("new DBs", () { setUp(removeFixtures); tearDown(removeFixtures);
test("creates a new DB", () {/*…*/}); }); }
Unit Tests // ... test("creates a new DB", () {
var db = new Dirty('test/test.db'); expect( new File('test/test.db').exists(), equals(true) ); });
test("can write to the DB", () { var db =
new Dirty('test/test.db'); db['everything'] = {'answer': 42}; db.close(expectAsync0(() { expect( new File('test/test.db').size(), greaterThan(0) ); })); }); Unit Tests
test("can write to the DB", () { var db =
new Dirty('test/test.db'); db['everything'] = {'answer': 42}; db.close(expectAsync0(() { expect( new File('test/test.db').size(), greaterThan(0) ); })); }); Unit Tests
Client-side Libraries import 'dart:html'; import 'dart:json'; import 'cookie.dart'; main() {
var cookie = new Cookie(12); }
Client-side Libraries class Cookie { var number_of_chips; Cookie(this.number_of_chips); }
Client-side Libraries library cookies; class Cookie { var number_of_chips; Cookie(this.number_of_chips);
}
Client-side Libraries import 'dart:html'; import 'dart:json'; import 'cookie.dart'; main() {
var cookie = new Cookie(12); }
Pub Packages $ cd public/scripts $ cat pubspec.yaml name: killer_app
dependencies: hipster_mvc: any $ pub install Resolving dependencies... Dependencies installed!
$ cd public/scripts $ cat pubspec.yaml name: killer_app dependencies: hipster_mvc:
any $ pub install Resolving dependencies... Dependencies installed! Pub Packages
Pub Packages $ cd public/scripts $ cat pubspec.yaml name: killer_app
dependencies: hipster_mvc: any $ pub install Resolving dependencies... Dependencies installed!
Pub Packages library cookie_model; import 'package:hipster_mvc/hipster_model. dart'; class Cookie extends
HipsterModel { Cookie(attributes) : super(attributes); }
Pub Packages • pub.dartlang.org • public git repositories • great
for local dev
Statically Typed Language
Statically Typed Language (but not really)
Statically Typed Language Sneakily
(Not Really) Static Typing class Cookie { var number_of_chips; Cookie(this.number_of_chips);
}
(Not Really) Static Typing class Cookie { int number_of_chips; Cookie(this.number_of_chips);
}
(Not Really) Static Typing class Cookie { int number_of_chips; Cookie(this.number_of_chips);
} var c1 = new Cookie(12); var c2 = new Cookie('salt'); print(""" c1: ${c1.number_of_chips} chips c2: ${c2.number_of_chips} chips""");
(Not Really) Static Typing class Cookie { int number_of_chips; Cookie(this.number_of_chips);
} c1: 12 chips c2: salt chips
$ dartanalyzer static_typing.dart 'String' is not assignable to 'int' 2:
var c1 = new Cookie(12); 3: var c2 = new Cookie('salt'); ~~~~~~ (Not Really) Static Typing
Dartdocs $ dartdoc cookie.dart
Dartdocs
Dartdocs /// A yummy, yummy food. class Cookie { ///
The number of chips in the /// cookie. The more the better. int number_of_chips; /// We do not support cookies /// without chips at this time. Cookie(this.number_of_chips); }
Dartdocs
Dartdocs
Dartdocs Documentation I didn't write
Dartdocs Documentation I didn't write
Dartdocs Class navigation
Dartdocs Search (client-side)
Dartdocs I ♥ Documentation
Dartdocs I ♥ Static Typing
I ♥ Dart
Thanks! Chris Strom @eee_c #pairwithme!!! Buy the book :) Also:
SPDY, Backbone.js, 3D Game Programming for Kids
Generative Constructors
Operators Overloading
Isolates
Futures