Download - Dart in Action
![Page 1: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/1.jpg)
in ActionAn introduction to the
Dart language and tools
![Page 2: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/2.jpg)
Who am I
● Technical Lead for Dart Editor at Google
● Former CTO at Instantiations
● Co-author of Eclipse Plug-insand Eclipse GEF
![Page 3: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/3.jpg)
Overview
● Motivation
● Language
● Tools
● Performance
● Demo
Special thanks to Seth Ladd, Florian Loitsch, Gilad Bracha, Steve Messick,
Brian Wilkerson, Alan Knight, and Eric Clayberg, for slides and ideas
![Page 4: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/4.jpg)
Web Programming
● Small apps are easy
● Platform independent
● No installation
● Platform improving fast
● Everywhere... and getting more modern
~50% of users on IE9/FF7/Chrome/Safari
![Page 5: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/5.jpg)
Why create Dart?
● Developing large applications is hard
○ Hard to find program structure○ No static types○ No support for libraries○ Weak tool support○ Slow startup
● Lots of cruft after 15 years
![Page 6: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/6.jpg)
Our goal... Help app developerswrite complex, highfidelity client appsfor the modern web
![Page 7: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/7.jpg)
Dart is ...
● Structured Web Programming
○ New language○ New tools○ New libraries
● Open source as of early October 2011
● Available at http://dartlang.org
![Page 8: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/8.jpg)
The Dart Language
● Object oriented language for the web
● Optional types
● Libraries, Isolates
● Real lexical scoping
● Single threaded
more at http://dartlang.org/language-tour/
![Page 9: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/9.jpg)
Hello World
more at http://dartlang.org/language-tour/
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
![Page 10: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/10.jpg)
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
Hello World
Libraries
more at http://dartlang.org/language-tour/
![Page 11: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/11.jpg)
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
Hello World
Functions
more at http://dartlang.org/language-tour/
![Page 12: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/12.jpg)
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
Hello World
Classes
more at http://dartlang.org/language-tour/
![Page 13: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/13.jpg)
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
Hello World
Methods
more at http://dartlang.org/language-tour/
![Page 14: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/14.jpg)
class Hello { void doStuff() { var message = "Hello World"; document.query('#status').innerHTML = message; }}
Hello World#import('dart:html'); void main() { new Hello().doStuff();}
Optional Types
more at http://dartlang.org/language-tour/
![Page 15: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/15.jpg)
class Hello { void doStuff() { String message = "Hello World"; document.query('#status').innerHTML = message; }}
#import('dart:html'); void main() { new Hello().doStuff();}
Hello World
Optional Types
more at http://dartlang.org/language-tour/
![Page 16: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/16.jpg)
Optional Static Types
● Low friction mechanism for communicating
intent to machines and other developers
● Easily scale up from prototype (untyped)
to production (typed)
● Increases your productivity
via Dart Editor and other tools
![Page 17: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/17.jpg)
Types At Runtime
● Developers may check types at runtime... T x = o assert(o === null || o is T)
● By default, types have○ No effect○ No runtime cost
![Page 18: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/18.jpg)
Isolates
● Inspired by Erlang
● Lightweight units of execution○ Each isolate conceptually a process
○ Nothing shared
○ All communication via message passing
● Support concurrent execution
Isolate 1spawn()
send port receive port
messages Isolate 1
![Page 19: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/19.jpg)
Isolates
● Can be ...○ Lightweight on UI thread
○ Heavyweight on their own thread
● Uses ...○ Isolate 3rd party code
○ JavaScript interop
○ Client / Server communication
![Page 20: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/20.jpg)
Dart Boardhttp://www.dartlang.org/
![Page 21: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/21.jpg)
Dart BoardSelect template
![Page 22: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/22.jpg)
Dart BoardType stuff
![Page 23: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/23.jpg)
Dart BoardRun program
![Page 24: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/24.jpg)
ToolsDart Source
Snapshot VMJavaScript
Tools
![Page 25: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/25.jpg)
Dart Editor
ToolsDart Source
Snapshot VMJavaScript
Tools
![Page 26: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/26.jpg)
Dart Editor Goals
● Easy to understand
● Introduce programmers to Dart
● Increase productivity○ Code completion, etc
● Fast
● Open Source and pre-built binary
○ Available at http://dartlang.org
![Page 27: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/27.jpg)
Dart Editor Users
● Web programmers of varying backgrounds
○ Many languages - HTML, JS, Python, Java
○ Wide range of programming experience
● Primarily not Eclipse users
![Page 28: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/28.jpg)
Dart Editor ... Before Where is Dart ??? Very cluttered UI
![Page 29: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/29.jpg)
Dart Editor Strategy
Narrow the scope
Focus on doing a few things well
Minimalist UIMake it easy to understandReduce decision making
![Page 30: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/30.jpg)
Dart Editor ... Now
Simple and Clean UI
![Page 31: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/31.jpg)
Dart Editor Strategy
● Single perspective
● Remove unnecessary plugins
● Redefine entire menu bar
● Use "activities" to supress UI elements
● Key binding schema
![Page 32: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/32.jpg)
Start-up Performance
● Remove unused pluginsModify plugins to remove dependencies
● Defer work until after UI appears○ Early startup extension point○ Display.asyncExec(...)
● Optimize load order○ Record class load order○ Reorder classes in plugin jar files
![Page 33: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/33.jpg)
Application Performance
● Profile and optimize the code○ Identify hotspots with VM profiler
○ Rewrite or eliminate slow code
● Defer work to background tasks
![Page 34: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/34.jpg)
Critical Performance Areas
● Background analysis (errors / warnings)
● Background indexing
● Code completion
● Dart to JavaScript compiler
![Page 35: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/35.jpg)
Metrics
First RCP build 65 MB170 plugins20s startup
Current build37 MB69 plugins4s startup
![Page 36: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/36.jpg)
Dart Is Not Done
● Reflection?
● Rest arguments?
● enum?
● Pattern matching?
● More browser integration?
![Page 37: Dart in Action](https://reader033.vdocument.in/reader033/viewer/2022051411/5439b2a5afaf9fb62e8b530d/html5/thumbnails/37.jpg)
Getting Involved
https://dartlang.orgIntroduction, language spec, articlesDownload Dart Editor
https://code.google.com/p/dart/Source code to editor, compiler, and virtual machineSee the wiki for instructions