Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
DartでWebアプリ その利点と課題
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
naotohc
June 06, 2015
Programming
430
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DartでWebアプリ その利点と課題
Dart Meetup Tokyo #1資料
http://dartisans-jp.connpass.com/event/15246/
naotohc
June 06, 2015
More Decks by naotohc
See All by naotohc
WebApp with PolymerDart and Material
ntaoo
0
710
@ntaoo
ntaoo
4
360
Other Decks in Programming
See All in Programming
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
350
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
120
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
220
Inertia Rails: The One-Person Framework with React & Friends
skryukov
0
380
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
200
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
300
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
300
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
410
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
220
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
1.2k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.7k
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Being A Developer After 40
akosma
PRO
92
590k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
68k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
800
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
The Cult of Friendly URLs
andyhume
79
7.1k
Transcript
DartでWebアプリ その利点と課題 @ntaoo (https://twitter.com/ntaoo) 2015/06/06
TOC 1. なぜDartなのか 2. 開発の振り返り 3. 利点と課題
なぜDartなのか
なぜDartを採用したか 現在開発しているアプリの特徴 Client, Server双方でDOM Treeをヘビーに探 索、操作する Kindle Cloud Readerのような感じ 多プラットフォーム(iOS,
Android, Win, Mac...)対応 デバイスAPIは使わない(今のところ)
なぜDartを採用したか Client, Serverで同一の言語、APIを使用可能 • Client : dart:html • Server :
package:html (package:html5 -> package:htmlに改名)
なぜDartなのか - 高い生産性 • リッチな標準API DOM API(html), Future, Stream, Lazy
Iterable, etc... https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/home • Pub package manager, serve, build, run, transformer https://pub.dartlang.org/ https://www.dartlang.org/tools/pub/assets-and-transformers.html (良くも悪くも) ライブラリ選定に悩む必要なし
なぜDartなのか - 高い生産性 • 型アノテーション, Optional Types 基本的に型宣言をするべき。必要があれば緩くする。ローカル変数へはお好みで省略。 https://www.dartlang.org/articles/optional-types/ •
静的解析ツール(analysis server) http://htmlpreview.github.io/?https://github.com/dart- lang/bleeding_edge/blob/master/dart/pkg/analysis_server/doc/api.html • analysis server等ツールのIDEへの統合 WebStormが素晴らしい! (https://www.jetbrains.com/webstorm/) dartfmt (https://www.dartlang.org/tools/dartfmt/)
TypeScript? 良い選択肢ですね!
Dart おさらい • シンプルで洗練された言語仕様(ここに価値を見いだせるかどうか) • 評価が定まっていない、または複雑性が増す仕様の採用には慎重 • Optional Types •
学習コスト低(特にJavaとJavaScriptのプログラマーにとって) • 容易な環境構築 • 高い生産性(読みやすい、書きやすい、デバッグしやすい、コンパイル早い) • 今日使えるFuture(Promise), Stream, async/await, Lazy Iterable • WebComponents library (WebUI -> PolymerDart)
DartVM on Chrome
DartVM Chromeへの搭載は見送り どこで使う? • 開発用ブラウザー(Dartium) • Server • Mobile(!?) •
Embed(!?) http://embeddeddart.blogspot.jp/2015/05/dart-on-pi-getting-started.html
開発の振り返り
開発の振り返り
構造 Client (SPA) : • 98% Dart 一部 JavaScript •
polymer_dart(v0.5.5), core_elements, paper_elements • 自前Client side routing(package: route_hierarchicalをwrap) • core-ajax未使用 View (Html, PolymerDart) <web-app> ViewModel (PolymerDart) Model (Dart domain model) Resource, Cache (Dart) </web-app> JSON request / response
構造 Server FrontEnd: GAE Python (default module) • JSON API
for client • DataStoreの操作 BackEnd: Dart on Appengine ManagedVMs • DOM Tree探索、操作等 • frontend serverからのrequestを受けて responseを返す関数。 Dart on appengineはまだβ版のため、いざとなれば Compute Engine 版に切り替えられるように設計。 BackEnd その他modules FrontEnd: Python default module BackEnd: Dart module その他modules JSON request / response JSON request / response Datastore
開発ワークフロー (Dart client) • pub serve • ブラウザのreloadでコードの反映 ◦ Dartium(1秒ほど。非常に早い)
◦ 他のモダンブラウザ(10秒ほど。自動的にJSのコンパイ ルが入るため) ローカル環境での開発中では、Nginx等を使用して各開発サーバー(pub dev server、GAE dev server、etc...)へのリクエストの振り分けを行う。
開発ワークフロー (Dart client) Debugger • WebStormを使おう • DartEditorは引退 Build (Compile
to JS, prepare for deployment) 1. pub build --mode=release(30秒) 2. gulp (imagemin, rev, etc...) * 必要ならば $ pub build --mode=release && gulp Grinderが将来Dartのgulp的存在になる? https://github.com/google/grinder.dart
PolymerDart • PolymerJSをpolymer_interlop packageでwrapしたもの • Dartで扱いやすいように記法を改善している • 2015/06/06現在、PolymerJSv0.5.5対応 • paper-elements,
core-elementsについてもwrapしてpub packageで提供 • Polymer Gestures未対応 PolymerJSv1.0 おめでとうございます PolymerJSがv1.0に到達して仕様が安定してからPolymerDartもupdateさせる方針 のようだったので、これからPolymerDartの1.0対応が始まる。
PolymerDart • モチベーション -> paper-elements, core-elementsを使いたい • PageごとにそのPage全体を司る一つのcustom elementを作成 •
全てをcustom elementで…とはしていない。core-ajaxとかcore-local-storage とか使ってない • Persistence(cache) layerやresource layerを作っている • Client side routingもcustom elementでなくroute_hierarchicalをwrapした自前 のcodeで表現 • まだ不安定版なのでバグを警戒(いろいろ怪しかったりピーキーだったり) • Custom elementsの作成は必要最小限に留める (v1.0まち)
PolymerDart • Model層にドメインモデルを構築して必要ならば@observableで変更をviewに 伝播させる class Foo extends Object with Observable
{ @observable bool isChosen = false; ... • テーマを適用するため、CoreStyle(外部cssをshadow dom内に適用)必須(v0. 5.5時点) • SCSS使用可能(pub sass transformer) • pub serve, pub build時にいろいろwarningを出してくれる https://www.dartlang.org/polymer/reference/error-messages/
硬く書く • factory constructor, static async construct methodを活用する • 基本immutable
objectにする
AngularDart? 様子見 (PolymerDartとDartSDKで概ね間に合っ ている) PolmyerDartとともに待ち望まれるクライアントサイ ドのキラーフレームワーク その他E2Eフレームワークの萌芽
利点と課題
利点 • 型宣言、静的解析 • リッチなSDK, Pub package manager • First
iteration cycle。コード変更の反映が早 い。1秒でブラウザに反映 • シンプルで洗練された言語仕様(悩まない) • EcmaScript NextをDartで先取り
課題 Buildで生成されるサイズ • index.htmlとindex.html.polymer.bootstrap.dart.js ◦ PolymerDartを使用すると500KB~。gzipして150KB~ ◦ 現在1000KB超。gzipして300KB ◦ gzipして300KBくらいを保つのが目標
◦ かなりマシになったとはいえ ◦ PolymerDartのvulcanizeではcommentをstripするoption(--strip-comments)がない ◦ PolymerJSv1.0対応で改善を期待 将来のdart2jsの改善, Dart Dev Compilerの開発による問題の軽減 そもそも信頼できるCache機構がWeb platformにあればこの問題は大幅に軽減される
課題 モバイル環境での初回load、cache問題 Dartだけでない。Webプラットフォームの課題 不安定な(モバイル)ネットワークへの対応。 Offline戦略重要 • ServiceWorkerによるcache -> 期待大。しかしMobile Safariに実装されるのはいつ?
• 起動に必要な部分のみ切り出し、残りは遅延ロードする方向性 Dynamic HTML Import (lazy loading) REF: io2015 Polymer session. https://www.youtube.com/watch?v=fD2As5RmM8Q • サーバーサイドプリレンダリング? • Cordovaなどでネイティブアプリ化し assetsを永続化 -> Webの利点(インストール操作なし、審査なし、いつでも最新版)を損なう
壁 • ライブラリ、フレームワークの革新がJS側で活発 • DartでJSのライブラリを書くことが事実上不可能 • 既存のJSのコードベースを段階的にDartに移行することが 困難 -> dart2jsの改善、Dart
Dev Compiler https://www.youtube.com/watch?v=2Ef3ALvbkhA https://www.youtube.com/watch?v=FiXiI2Atexc • 英語の壁?
おまけ DEP(Dart Enhancement Proposal) Non-null Types and Non-null By Default
(NNBD) https://github.com/chalin/DEP-non-null/blob/master/doc/dep-non-null- AUTOGENERATED-DO-NOT-EDIT.md