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
99
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
78
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
84
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
60
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
75
PyCon2014China-Zhuhai-jeff
zoomquiet
0
56
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
84
DevFest2014-Zhuhai-Polymer
zoomquiet
0
360
Other Decks in Technology
See All in Technology
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
110
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
TypeScript、上達の瞬間
sadnessojisan
46
13k
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
6
670
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
Platform Engineering for Software Developers and Architects
syntasso
1
510
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Featured
See All Featured
Teambox: Starting and Learning
jrom
133
8.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Automating Front-end Workflow
addyosmani
1366
200k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Docker and Python
trallard
40
3.1k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
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