Dart An Introduction Florian Loitsch <floitsch@google.com> - - PowerPoint PPT Presentation

dart
SMART_READER_LITE
LIVE PREVIEW

Dart An Introduction Florian Loitsch <floitsch@google.com> - - PowerPoint PPT Presentation

Dart An Introduction Florian Loitsch <floitsch@google.com> October 19, 2011 Florian Loitsch Dart October 19, 2011 1 / 31 1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source


slide-1
SLIDE 1

Dart

An Introduction Florian Loitsch <floitsch@google.com> October 19, 2011

Florian Loitsch Dart October 19, 2011 1 / 31

slide-2
SLIDE 2

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

Florian Loitsch Dart October 19, 2011 2 / 31

slide-3
SLIDE 3

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-4
SLIDE 4

A Structured Web Programming Language

Dart, a structured web programming language:

  • New programming language.
  • New programming tools.
  • New open source project.

Warning: this is a technology preview.

Florian Loitsch Dart October 19, 2011 4 / 31

slide-5
SLIDE 5

Current Web

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.

Florian Loitsch Dart October 19, 2011 5 / 31

slide-6
SLIDE 6

Current Web cont.

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.

Florian Loitsch Dart October 19, 2011 6 / 31

slide-7
SLIDE 7

Innovation is Essential

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 pitfalls.

Florian Loitsch Dart October 19, 2011 7 / 31

slide-8
SLIDE 8

Design Goals

Design Goals for Dart:

  • Structured yet flexible programming language for

the web.

  • Familiar and natural to programmers.
  • Appropriate for the full range of devices on the web.
  • Tools to support all major modern browsers.

Florian Loitsch Dart October 19, 2011 8 / 31

slide-9
SLIDE 9

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-10
SLIDE 10

So What Is Dart?

  • Unsurprisingly object-oriented programming

language.

  • Class-based single inheritance with interfaces.
  • Optional static types.
  • Proper lexical scoping.
  • Single-threaded.
  • Familiar syntax.

Florian Loitsch Dart October 19, 2011 10 / 31

slide-11
SLIDE 11

First code

Let’s Try Some Dart Code

  • Fun with classes, closures, and optional types.
  • Easy to experiment with at try.dartlang.org.

Florian Loitsch Dart October 19, 2011 11 / 31

slide-12
SLIDE 12

Types

  • 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 are innocent until proven guilty.

Florian Loitsch Dart October 19, 2011 12 / 31

slide-13
SLIDE 13

Optional

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.

Florian Loitsch Dart October 19, 2011 13 / 31

slide-14
SLIDE 14

Types on the Dartboard

  • Let’s explore a few illustrative examples.

Florian Loitsch Dart October 19, 2011 14 / 31

slide-15
SLIDE 15

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-16
SLIDE 16

Isolates

  • Isolates are lightweight units of execution:
  • Run in their own address space like processes.
  • Nothing is shared - nothing needs synchronization.
  • All communication takes place via message passing.
  • Supports concurrent execution.

Florian Loitsch Dart October 19, 2011 16 / 31

slide-17
SLIDE 17

Sending and Receiving Messages

Florian Loitsch Dart October 19, 2011 17 / 31

slide-18
SLIDE 18

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, transferable capability.

Florian Loitsch Dart October 19, 2011 18 / 31

slide-19
SLIDE 19

Isolates: Example

  • Dartboard supports isolates.
  • Easy to illustrate the core primitives.

Let’s see some code.

Florian Loitsch Dart October 19, 2011 19 / 31

slide-20
SLIDE 20

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-21
SLIDE 21

Dart Execution

Dart Source T

  • ols

JavaScript Engine Snapshot Dart VM

DartC

Florian Loitsch Dart October 19, 2011 21 / 31

slide-22
SLIDE 22

Dart Performance

Relative performance compared to JavaScript on V8. Benchmark VM DartC Mandelbrot 18.2% 88.7% DeltaBlue 56.6% 52.2% Richards 56.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.

Florian Loitsch Dart October 19, 2011 22 / 31

slide-23
SLIDE 23

Dart VM: Snapshotting

Dart VM and snapshotting.

  • Process of serializing the heap after loading the

application.

  • Loading 54173 lines of Dart code takes 640ms.
  • Loading same application from a snapshot takes

60ms.

  • Startup > 10x faster.

Florian Loitsch Dart October 19, 2011 23 / 31

slide-24
SLIDE 24

Web Application in Dart

Sample web application in Dart:

  • News reader completely written in Dart.
  • Application code: 3210 LOC.
  • UP library code: 13200 LOC.
  • Animation yields 30 fps.
  • Code is part of the open source project.

Florian Loitsch Dart October 19, 2011 24 / 31

slide-25
SLIDE 25

Editor

  • Editor for constructing and browsing Dart

applications.

  • Lightweight editor based on Eclipse components.
  • Code is part of the open source project.

Florian Loitsch Dart October 19, 2011 25 / 31

slide-26
SLIDE 26

Not Done Yet

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.

Florian Loitsch Dart October 19, 2011 26 / 31

slide-27
SLIDE 27

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-28
SLIDE 28

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

Florian Loitsch Dart October 19, 2011 28 / 31

slide-29
SLIDE 29

Outline

1 Introduction 2 How does it look and feel? 3 What is this thing about isolates? 4 Execution model 5 Open-source project 6 Conclusion

slide-30
SLIDE 30

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.

Florian Loitsch Dart October 19, 2011 30 / 31

slide-31
SLIDE 31

Questions

Q & A.

Florian Loitsch Dart October 19, 2011 31 / 31