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
89
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
140
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
110
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
87
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
86
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
71
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
84
PyCon2014China-Zhuhai-jeff
zoomquiet
0
65
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
95
DevFest2014-Zhuhai-Polymer
zoomquiet
0
380
Other Decks in Technology
See All in Technology
トラシューアニマルになろう ~開発者だからこそできる、安定したサービス作りの秘訣~
jacopen
2
2k
Culture Deck
optfit
0
420
個人開発から公式機能へ: PlaywrightとRailsをつなげた3年の軌跡
yusukeiwaki
11
3k
Swiftの “private” を テストする / Testing Swift "private"
yutailang0119
0
130
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.6k
Platform Engineeringは自由のめまい
nwiizo
4
2.1k
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
710
Oracle Cloud Infrastructure:2025年2月度サービス・アップデート
oracle4engineer
PRO
1
210
Helm , Kustomize に代わる !? 次世代 k8s パッケージマネージャー Glasskube 入門 / glasskube-entry
parupappa2929
0
250
人はなぜISUCONに夢中になるのか
kakehashi
PRO
6
1.7k
モノレポ開発のエラー、誰が見る?Datadog で実現する適切なトリアージとエスカレーション
biwashi
6
810
AndroidデバイスにFTPサーバを建立する
e10dokup
0
250
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
A designer walks into a library…
pauljervisheath
205
24k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
GraphQLとの向き合い方2022年版
quramy
44
13k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Rails Girls Zürich Keynote
gr2m
94
13k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
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