kasper lund yow! melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/dart-yow.pdf · current...

27
Kasper Lund YOW! Melbourne - 2011 Friday, December 2, 2011

Upload: others

Post on 07-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

Kasper LundYOW! Melbourne - 2011

Friday, December 2, 2011

Page 2: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART: A STRUCTURED WEB PROGRAMMING LANGUAGE

• New programming language

• New programming tools

• New open source project

WARNING: THIS IS ONLY A TECHNOLOGY PREVIEW

Friday, December 2, 2011

Page 3: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

MY PROJECTS• CLDC HI - fast Java virtual machine for cell phones

• OOVM - embedded yet serviceable Smalltalk

• V8 - high-performance JavaScript virtual machine

• Dart - structured programming for the web

Friday, December 2, 2011

Page 4: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

AGENDA• Why did we design a new language?

• How does it look and feel?

• What is this thing about isolates?

• Open-source project

Friday, December 2, 2011

Page 5: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

CURRENT WEB: THE GOOD PARTS

• JavaScript is flexible and supports incremental development

• Developing and deploying small applications is easy

• Platform independent execution - code runs everywhere

• No installation of applications

Friday, December 2, 2011

Page 6: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

CURRENT WEB: THE BAD PARTS

• Writing large well-performing applications is hard

• Hard to reason about the program structure

• Startup performance is often really bad

• Difficult to document intent and interfaces (lack of types)

• No support for modules, packages, or libraries

• Comparatively weak tool support

Friday, December 2, 2011

Page 7: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

INNOVATION IS ESSENTIAL• The Web platform must keep moving fast and innovate

• There is a clear need for supporting programming in the large

• JavaScript is a powerful tool but it has many sharp edges

Friday, December 2, 2011

Page 8: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

HISTORY BEHIND DART• Last year, Lars Bak and I experimented with Spot

• A new simple programming language for the web

• Based on the experiences from JavaScript

• Spot was the prelude for the Dart project

I’m Lars

Friday, December 2, 2011

Page 9: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

SO WHAT IS DART?

• Unsurprising object-oriented programming language

• Class-based single inheritance with interfaces

• Optional static types

• Proper lexical scoping

• Single-threaded

• Familiar syntax

Friday, December 2, 2011

Page 10: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

LET’S TRY SOME DART CODE

• Fun with classes, closures, and optional types

• Easy to experiment with at try.dartlang.org

Friday, December 2, 2011

Page 11: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

A DIFFERENT TYPE-CHECKER

• A conventional type-checker

• ... tries to prove that your program obeys the type system

• ... considers it a fatal error if it cannot construct a proof

• In Dart, you’re innocent until proven guilty

Friday, December 2, 2011

Page 12: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

OPTIONAL STATIC TYPES

• Static types convey the intent of the programmer

• Checkable documentation for code and interfaces

• Avoids awkward variable naming schemes

• Type annotations have no effect on the runtime semantics...

Friday, December 2, 2011

Page 13: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

TYPES ON THE DARTBOARD

• Let’s explore a few illustrative examples

Friday, December 2, 2011

Page 14: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

ISOLATES• Lightweight units of execution

• Runs in their own address space like processes

• Nothing is shared - nothing needs synchronization

• All communication takes place via message passing

• Supports concurrent execution

Friday, December 2, 2011

Page 15: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

SENDING AND RECEIVING MESSAGES= receive port

= send port

Friday, December 2, 2011

Page 16: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

PORTS• Receive ports accept and enqueue incoming messages

• Live inside a specific isolate

• Can be created on demand

• A send port allows sending to a certain receive port

• It is an unforgeable, transferrable capability

Friday, December 2, 2011

Page 17: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

ISOLATES: LET’S SEE THE CODE• Dartboard supports isolates

• Easy to illustrate the core primitives

Friday, December 2, 2011

Page 18: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART EXECUTIONDart Source

JavaScript Engine

Dart VM

Tools

Snapshot

TextDartC

Friday, December 2, 2011

Page 19: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

FROG: SELF-HOSTING COMPILER• Dart-to-JavaScript compiler implemented in Dart

• Runs on top of the native Dart VM

• Self-hosts on top of node.js or the V8 developer shell (d8)

• Uses simple tree shaking to generate less code

• Experimenting with an SSA-based optimizing backend

Friday, December 2, 2011

Page 20: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART PERFORMANCERelative performance compared to JavaScript on V8Benchmark            VM   DartCMandelbrot:       18.2%   88.7%DeltaBlue:        56.6%   52.2%Richards:         46.0%   70.9%NBody:            35.8%   63.6%BinaryTrees:      77.3%  104.3%Fannkuch:         53.8%   22.3%Meteor:           50.3%   42.1%

Details: - V8 revision 3.5.5. - DartC used with the -optimize flag

Friday, December 2, 2011

Page 21: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART VM: SNAPSHOTTING• Process of serializing the heap after loading the application

• Loading 54173 lines of Dart code takes 640 ms

• Loading same application from a snapshot takes 60 ms

• Startup > 10x faster

Friday, December 2, 2011

Page 22: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

WEB APPLICATION IN DART• News reader completely written in Dart

• Application code: 3210 LOC

• UI library code: 13200 LOC

• Animation yields 30 fps

• Code is part of the open source project

Friday, December 2, 2011

Page 23: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART EDITOR• Editor for constructing and browsing Dart applications

• Lightweight editor based on Eclipse components

• Code is part of the open source project

Friday, December 2, 2011

Page 24: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART IS NOT DONE• Rest arguments and enums?

• Reflection support?

• Pattern matching for easy message decoding like in Erlang?

• ... please give feedback by joining the discussions

Friday, December 2, 2011

Page 25: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART OPEN SOURCE PROJECT• The Dart web site: http://dartlang.org

• Dart language specification

• Dart language tutorial

• The Dart project: http://dart.googlecode.com

• Libraries and code samples

• Dart virtual machine

• Dart-to-JavaScript compiler

Friday, December 2, 2011

Page 26: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

DART IS A TECHNOLOGY PREVIEW• Dart: structured programming for the web

• Two execution modes: Dart VM or JavaScript engine

• Compatible with the current web

• Please try it out and participate

Friday, December 2, 2011

Page 27: Kasper Lund YOW! Melbourne - 2011gotocon.com/dl/jaoo-melbourne-2011/slides/Dart-YOW.pdf · CURRENT WEB: THE BAD PARTS • Writing large well-performing applications is hard • Hard

Q & AFriday, December 2, 2011