dart in action

37
in Action An introduction to the Dart language and tools

Upload: ewketbirhan-alemu

Post on 10-Oct-2014

235 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Dart in Action

in ActionAn introduction to the

Dart language and tools

Page 2: Dart in Action

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

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

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

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

Our goal... Help app developerswrite complex, highfidelity client appsfor the modern web

Page 7: Dart in Action

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

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

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

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

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

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

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

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

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

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

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

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

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

Dart Boardhttp://www.dartlang.org/

Page 21: Dart in Action

Dart BoardSelect template

Page 22: Dart in Action

Dart BoardType stuff

Page 23: Dart in Action

Dart BoardRun program

Page 24: Dart in Action

ToolsDart Source

Snapshot VMJavaScript

Tools

Page 25: Dart in Action

Dart Editor

ToolsDart Source

Snapshot VMJavaScript

Tools

Page 26: Dart in Action

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

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

Dart Editor ... Before Where is Dart ??? Very cluttered UI

Page 29: Dart in Action

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

Dart Editor ... Now

Simple and Clean UI

Page 31: Dart in Action

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

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

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

Critical Performance Areas

● Background analysis (errors / warnings)

● Background indexing

● Code completion

● Dart to JavaScript compiler

Page 35: Dart in Action

Metrics

First RCP build 65 MB170 plugins20s startup

Current build37 MB69 plugins4s startup

Page 36: Dart in Action

Dart Is Not Done

● Reflection?

● Rest arguments?

● enum?

● Pattern matching?

● More browser integration?

Page 37: Dart in Action

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