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
82
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
84
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
67
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
80
PyCon2014China-Zhuhai-jeff
zoomquiet
0
60
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
91
DevFest2014-Zhuhai-Polymer
zoomquiet
0
370
Other Decks in Technology
See All in Technology
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
170
技術に触れたり、顔を出そう
maruto
1
150
なぜfreeeはハブ・アンド・スポーク型の データメッシュアーキテクチャにチャレンジするのか?
shinichiro_joya
2
490
AIアプリケーション開発でAzure AI Searchを使いこなすためには
isidaitc
1
120
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
2.4k
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
6.5k
JuliaTokaiとJuliaLangJaの紹介 for NGK2025S
antimon2
1
120
ドメイン駆動設計の実践により事業の成長スピードと保守性を両立するショッピングクーポン
lycorptech_jp
PRO
13
2.2k
Visual StudioとかIDE関連小ネタ話
kosmosebi
1
380
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
JAWS-UG20250116_iOSアプリエンジニアがAWSreInventに行ってきた(真面目編)
totokit4
0
140
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
46
7.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
A designer walks into a library…
pauljervisheath
205
24k
Music & Morning Musume
bryan
46
6.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Thoughts on Productivity
jonyablonski
68
4.4k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Building an army of robots
kneath
302
45k
How STYLIGHT went responsive
nonsquared
96
5.3k
Documentation Writing (for coders)
carmenintech
67
4.5k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Building Your Own Lightsaber
phodgson
104
6.2k
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