YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: 20ヶ月を取り戻す Dart flight school

20ヶ月を取り戻す

わかめ まさひろ

Page 2: 20ヶ月を取り戻す Dart flight school

わかめ まさひろ@v vakame

GAE

AndroidTypeScript

AngularJSGlass

Page 3: 20ヶ月を取り戻す Dart flight school

2012年05月12日

Page 4: 20ヶ月を取り戻す Dart flight school

Dartハッカソン!

Page 5: 20ヶ月を取り戻す Dart flight school

Winner!うちのチーム勝ちました!

Page 6: 20ヶ月を取り戻す Dart flight school

BDDテスト的なの作った

http://vvakame.github.io/teaolive/old/

#library('teaolive_introduction'); !#import('dart:html'); #import('packages/teaolive/teaolive.dart'); #import('packages/teaolive/reporter/reporter_combinator.dart', prefix: 'combinator'); #import('packages/teaolive/reporter/tap_reporter.dart', prefix: 'tap'); #import('packages/teaolive/reporter/html_reporter.dart', prefix: 'html'); !void main() { addTest(testCase); setTeaoliveReporter( new combinator.TeaoliveReporterCombinator( [ new html.TeaoliveHtmlReporter(), new tap.TeaoliveTapReporter() ] )); teaoliveRun(); } !void testCase() { describe("A suite", (){ it("contains spec with an expectation", (){ expect(true).toBe(true); }); }); }

Page 7: 20ヶ月を取り戻す Dart flight school

時は流れ…

20 month later…

Page 8: 20ヶ月を取り戻す Dart flight school

Version History• 2012/10/16 M1!

• 2012/12/18 M2!

• 2013/02/20 M3!

• 2013/04/16 M4!

• 2013/06/19 M5-Beta!

!

• 2013/08/27 M6-Beta!

• 2013/10/02 M7-Beta!

• 2013/11/14 1.0!

• 2014/01/16 1.1

イベント中アプデの法則で 本日 1.1.4の可能性が

微粒子レベルで存在…?

まぁないだろ

goo.gl/mtSRKL

Page 9: 20ヶ月を取り戻す Dart flight school

コンパイル できない…

ハッカソン当時は0.0.8とか

Page 10: 20ヶ月を取り戻す Dart flight school

当時の思い出• unittestのライブラリ!

• bleeding_edgeにしかない!

• 使い方もよくわかんない!

• pub (Dartパッケージ管理システム)!

• 立ち上げるぞ!みたいな時期!

• まだ影も形もほとんどなかったTypeScriptもなかった

Page 11: 20ヶ月を取り戻す Dart flight school

直した

http://vvakame.github.io/teaolive/

library teaolive_introduction; !import 'dart:async'; import 'package:teaolive/teaolive_browser.dart'; !void main() { addTest(testCase); setTeaoliveReporter( new TeaoliveReporterCombinator( [ new TeaoliveHtmlReporter(), new TeaoliveTapReporter() ] )); teaoliveRun(); } !void testCase() { describe("A suite", (){ it("contains spec with an expectation", (){ expect(true).toBe(true); }); }); }

Page 12: 20ヶ月を取り戻す Dart flight school

途中経過

だいたい4時間で 直せた!

Page 13: 20ヶ月を取り戻す Dart flight school

古いDart Editorを使おう• 古いコードのMigration機能がある!

• http://goo.gl/ae2KIL!• 誰の提供か謎なので少し怖い!

• build 12784, 18717!• M4くらいから無くなったぽい!

• プロジェクト右クリ→Clean up!

• diff http://goo.gl/y9zX5q

Page 14: 20ヶ月を取り戻す Dart flight school

1.1.3に対応しよう• ちゃんと最新のDartEditor使う!• とりあえずコンパイルを通す!

• http://goo.gl/PLIASf!• API変更による修正が主!• 構文上の修正は少ない!

• デフォルト値付き省略可能引数!• 例外処理周り!• dynamicへのキャスト方法

Page 15: 20ヶ月を取り戻す Dart flight school

まだまだ…

• 文法的に正しくてもWarningが残る!

• Runtime ErrorになるWarning多い!!

• なぜErrorにしてくれないのか!!

• 文化が変わったところに対応!

• ちょっとやりきってないけど><

Page 16: 20ヶ月を取り戻す Dart flight school

文化の変化

おやじギャグではない

Page 17: 20ヶ月を取り戻す Dart flight school

pub• パッケージマネージャ!

• RubyGems, CPAN, npm, Mavenとか!

• かなりよく出来てる!!

• pubを中心とした規約!

• pubspec.yamlとか!

• フォルダ構成とか

Page 18: 20ヶ月を取り戻す Dart flight school

標準構成!web/ に置くと決まってる

pub build するとここに出る

TodoMVC サンプルコードより

goo.gl/nFDqwu

Page 19: 20ヶ月を取り戻す Dart flight school

標準構成!

直接公開しないコードは srcの下に置く

配布ライブラリはlibに置く

teaoliveより

goo.gl/nFDqwu

Page 20: 20ヶ月を取り戻す Dart flight school

組込ライブラリとpub

Page 21: 20ヶ月を取り戻す Dart flight school

組込ライブラリとpub#import('dart:io'); #import('dart:uri'); void main() { String payload; HttpClient client = new HttpClient(); HttpClientConnection connection = client.getUrl(new Uri.fromString(http://vvakame.github.io/teaolive/")); connection.onResponse = (HttpClientResponse response){ StringBuffer buffer = new StringBuffer(); InputStream input = response.inputStream; input.onData = (){ buffer.add(new String.fromCharCodes(input.read())); }; input.onClosed = (){ client.shutdown(); payload = buffer.toString(); print(payload); }; }; }

0.0.8くらい

Page 22: 20ヶ月を取り戻す Dart flight school

組込ライブラリとpub

import 'package:http/http.dart' as http; void main() { var client = new http.Client(); client.get("http://vvakame.github.io/teaolive/") .then((response) { print(response.body); }); }

1.1.3 + pub

Page 23: 20ヶ月を取り戻す Dart flight school

Future oriented language

• DartはFuture(Promise)を基盤に据えた!

• っぽい!

• 個人の感想かも!?教えて偉い人!!

• http://goo.gl/ru2Tu6!

• (取組みが)ES6 Promiseよりはやーい!

Page 24: 20ヶ月を取り戻す Dart flight school

言語の変化

細かい事はわからん!

Page 25: 20ヶ月を取り戻す Dart flight school

ナウくなった• Editor上で簡単な型推論とかできるぽい!

• var client = new http.Client() 的な!• ライブラリを複数ファイルで構成可能!

• library hoge と part of hoge!

• analyzerが割りと頭良い!• 複数ファイルから参照されている場合全てのユースケースでのWarning出す

Page 26: 20ヶ月を取り戻す Dart flight school

dart:js• http://goo.gl/GOktnP!

• 頑張ればJavaScript呼べるようになった!

• すごい!postMessageとかじゃない!!

• TypeScriptの型定義ファイル役に立つ?!

• .d.tsからDartラッパ自動生成できる?!

• Dartisanに型定義ファイル書かせよ❤

Page 27: 20ヶ月を取り戻す Dart flight school

dart:mirrors• Mirror based reflection!

• ちゃんと実装されたらしい!

• あれっ!? goo.gl/S9bRCg!

• JavaのJSR269感を感じる…!

• 同じ考え方のものかな?!

• シンボルが導入された #hoge!

• いいなーJavaScriptにも欲しい

Page 28: 20ヶ月を取り戻す Dart flight school

更に詳しくしりたい時

Dart(流行れば)良い言語

Page 29: 20ヶ月を取り戻す Dart flight school

参考資料• 株式会社クレスさんがヤバい!

• Dartの基礎!! goo.gl/M1Nul8!

• Dart仕様邦訳!goo.gl/MAl6SN!

• Cheat Sheet!

• goo.gl/ceTqb超初期からコツコツと…!

Page 30: 20ヶ月を取り戻す Dart flight school

お時間どうですかー?

Page 31: 20ヶ月を取り戻す Dart flight school

    宣伝 (しかしAndroidだ

Page 32: 20ヶ月を取り戻す Dart flight school

クレスさん資料より• 抽象クラス増えた!• mix-in 増えた!• Stream 導入!

• java.util.stream, Node.js EventEmitter!• 関数エミュレーション!

• TypeScriptでいうcall signature!• metaデータ!• Windows XP 非サポートに


Related Documents