an introduction - goto conferencegotocon.com/dl/goto-prague-2011/slides/karlkrukow... · an...

43
Karl Krukow, Software Engineer, Trifork [email protected] an introduction tirsdag den 22. november 11

Upload: others

Post on 22-May-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Karl Krukow,

Software Engineer, Trifork

[email protected]

an introduction

tirsdag den 22. november 11

Page 2: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

About me

• PhD, 2006, Computer Science, University of Aarhus, Denmark (Theory-stuff :)

• Software Engineer at Trifork

–Web, JavaScript, Java, Ruby, Clojure, Mobile.

– Co-authoring a Dart book by Kresten Krab Thorup!

• Co-owner of a start-up, LessPainful, doing cloud- based automated testing for native mobile: http://www.lesspainful.com

tirsdag den 22. november 11

Page 3: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

What is Dart?

3

tirsdag den 22. november 11

Page 4: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

What is Dart?

• Three things– A new programming language, supporting

structured programming for the web.

– Set of tools supporting development with Dart.

– Open source project

3

tirsdag den 22. november 11

Page 5: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

What is Dart?

• Three things– A new programming language, supporting

structured programming for the web.

– Set of tools supporting development with Dart.

– Open source project

• Important to remember:– THIS IS A TECHNOLOGY PREVIEW

(don’t put it in production just yet).

3

tirsdag den 22. november 11

Page 6: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Who?

4

tirsdag den 22. november 11

Page 7: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Who?

• Language and VM expert team at Google, some highlights:– Lars Bak (High-perf. VMs, Strongtalk, OOVM,

Hotspot, V8,...)

– Gilad Bracha (Newspeak, Strongtalk, JLS, types...)

– Kasper Lund (CLDC HI, OOVM, V8, Spot, ...)

4

tirsdag den 22. november 11

Page 8: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Why?

5

tirsdag den 22. november 11

Page 9: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Why?

5

• JavaScript is focused on flexibility+ease of use– Hard to reason about the program structure.– No direct support for modularity

– Comparatively weak tool support.

– In the wild: unstructured, lang. mix, dependencies

• Security– 3rd party code runs at same priviledge as ours

tirsdag den 22. november 11

Page 10: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

In the wild: user experience

6

tirsdag den 22. november 11

Page 11: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

6

tirsdag den 22. november 11

Page 12: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

6

tirsdag den 22. november 11

Page 13: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

6

Start-up performance is often really bad.

tirsdag den 22. november 11

Page 14: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Potential advantages of Dart

7

tirsdag den 22. november 11

Page 15: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Potential advantages of Dart• Tool support

• Fairly “low ceremony” with (optional) types

• Unified language

• Concurrency without “lock-and-pray”.

• Security (sandbox + capabilities)

• Performance

• Simplified library interoperability (“imports”)

7

tirsdag den 22. november 11

Page 16: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

The Dart Programming Language

8

tirsdag den 22. november 11

Page 17: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Main language features

9

tirsdag den 22. november 11

Page 18: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Main language features

• Pure object-oriented dynamic programming language. Familiar syntax.

– Class-based single inheritance with interfaces.– Implicit interfaces, factories.

9

tirsdag den 22. november 11

Page 19: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Main language features

• Pure object-oriented dynamic programming language. Familiar syntax.

– Class-based single inheritance with interfaces.– Implicit interfaces, factories.

• Optional static typing

9

tirsdag den 22. november 11

Page 20: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Main language features

• Pure object-oriented dynamic programming language. Familiar syntax.

– Class-based single inheritance with interfaces.– Implicit interfaces, factories.

• Optional static typing

• Isolates: message-passing model for concurrency– Isolates are single threaded.

– basis for a capability-based security model

9

tirsdag den 22. november 11

Page 21: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Dart on server: typically on dartvmDart on client: dartvm in browser, JS in browser

tirsdag den 22. november 11

Page 22: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Let’s see it!

11

Classes, interfaces, closures.Optional types.

tirsdag den 22. november 11

Page 23: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on Dart’s optional types

12

tirsdag den 22. november 11

Page 24: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on Dart’s optional types• Annotations don’t affect runtime semantics!

12

tirsdag den 22. november 11

Page 25: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on Dart’s optional types• Annotations don’t affect runtime semantics!• Controversial: Type system is actually

‘unsound’, e.g., co-variant generics.• “Ergonomically incorrect” - G. Bracha

12

tirsdag den 22. november 11

Page 26: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on Dart’s optional types• Annotations don’t affect runtime semantics!• Controversial: Type system is actually

‘unsound’, e.g., co-variant generics.• “Ergonomically incorrect” - G. Bracha

• Reified types: type args to constructors, interfaces.

12

tirsdag den 22. november 11

Page 27: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on Dart’s optional types• Annotations don’t affect runtime semantics!• Controversial: Type system is actually

‘unsound’, e.g., co-variant generics.• “Ergonomically incorrect” - G. Bracha

• Reified types: type args to constructors, interfaces.

• “Checked mode”: runtime checks of annotations.

12

tirsdag den 22. november 11

Page 28: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Ergonomically incorrect

13

tirsdag den 22. november 11

Page 29: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Ergonomically incorrect

13

public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) { ...}

tirsdag den 22. november 11

Page 30: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Ergonomically incorrect

13

public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) { ...}

Comparable max(List<Comparable> list) { ...}

vs

tirsdag den 22. november 11

Page 31: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Isolates

14

• Lightweight units of execution.

• Runs in their own address space like processes.

• All communication takes place via message passing

• Each isolate is “sequential”/single threaded

– Dart supports concurrent execution by spawning multiple isolates.

• Only message queues shared, no locks needed!

tirsdag den 22. november 11

Page 32: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Isolates

15

tirsdag den 22. november 11

Page 33: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

More on ports

• Receive ports accept and enqueue incoming messages

– An isolate is born with a receive port.

– Can also be created on demand.

• A send port allows sending to a certain receive port– It is an unforgeable, transferrable capability

– Basis for sandboxing untrusted code.

16

tirsdag den 22. november 11

Page 34: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

17

Isolates

Let’s see it!

tirsdag den 22. november 11

Page 35: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Performance

• Now, DartVM isn’t generally faster than V8.

• But Dart is likely to go faster than V8 will – due to simplified semantics of Dart compared to

JavaScript.

18

tirsdag den 22. november 11

Page 36: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Snapshots

• Serialized heap after loading the application

• Startup can be more than 10x faster• Example:– Loading 54173 lines of Dart code takes 640

ms– Loading same application from a snapshot

takes 60 ms•

19

tirsdag den 22. november 11

Page 37: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Open source project

• The Dart web site: http://dartlang.org– Dart language specification

– Dart language tutorial + articles

• The Dart project: http://dart.googlecode.com• Libraries and code samples• Dart virtual machine+ JavaScript compiler(s)• http://try-dart-lang.appspot.com

20

tirsdag den 22. november 11

Page 38: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

DART IS NOT DONE

• Give feedback by joining the discussion!– Some of the features aren’t implemented yet...

– Rest arguments and enums?

– Reflection support?– Isolates are kind-of low-level...

21

tirsdag den 22. november 11

Page 39: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

22

Watch out for the upcoming Dart book!

Thanks.Questions?

tirsdag den 22. november 11

Page 40: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Surprisingly Unsurprising?

23

tirsdag den 22. november 11

Page 41: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Surprisingly Unsurprising?• Why isn’t Dart more like:

• Clojure, Erlang, Haskell, Scala, <exotic language X>

23

tirsdag den 22. november 11

Page 42: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Surprisingly Unsurprising?• Why isn’t Dart more like:

• Clojure, Erlang, Haskell, Scala, <exotic language X>

• Deliberately designed to be familar:• developed with massive-adoption as primary goal.

23

tirsdag den 22. november 11

Page 43: an introduction - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/KarlKrukow... · an introduction tirsdag den 22. november 11. About me • PhD, 2006, Computer Science, University

Surprisingly Unsurprising?• Why isn’t Dart more like:

• Clojure, Erlang, Haskell, Scala, <exotic language X>

• Deliberately designed to be familar:• developed with massive-adoption as primary goal.

• Also, focus on enabling high performance and powerful tooling.+ Must compile to efficient JavaScript.

23

tirsdag den 22. november 11