a walk on the dart side
play

A Walk on the Dart Side A Quick Tour of ext Gilad Bracha Joint Work - PowerPoint PPT Presentation

A Walk on the Dart Side A Quick Tour of ext Gilad Bracha Joint Work with the Dart Team Saturday, November 19, 2011 1 Dart at 50,000 feet Language for Web Programming Sophisticated Web Applications need not be a tour de force Saturday,


  1. A Walk on the Dart Side A Quick Tour of ext Gilad Bracha Joint Work with the Dart Team Saturday, November 19, 2011 1

  2. Dart at 50,000 feet Language for Web Programming Sophisticated Web Applications need not be a tour de force Saturday, November 19, 2011 2

  3. Constraints Instantly familiar to the mainstream programmer E ffi ciently compile to Javascript Saturday, November 19, 2011 3

  4. Dart in a Nutshell Purely Object-Oriented, optionally typed, class-based, single inheritance with actor-based concurrency Saturday, November 19, 2011 4

  5. So what’s so interesting? Pure Object-Oriented, optionally typed , class-based, single inheritance with actor-based concurrency Saturday, November 19, 2011 5

  6. Some Modest Innovations Optional types Built-in Factory Support ADTs without types Saturday, November 19, 2011 6

  7. Some Modest Innovations Optional types ADTs without types Built-in Factory Support Saturday, November 19, 2011 7

  8. Some Modest Innovations Optional types ADTs without types Built-in Factory Support Saturday, November 19, 2011 8

  9. Mandatory Types Optional Types Saturday, November 19, 2011 9

  10. Mandatory Types Static type system regarded as mandatory Maltyped programs are illegal Saturday, November 19, 2011 10

  11. A Brief History of non-mandatory Types Common Lisp Scheme (soft typing) Cecil Erlang Strongtalk BabyJ Gradual Typing Saturday, November 19, 2011 11

  12. A Brief History of non-mandatory Types Common Lisp Scheme (soft typing) Cecil Erlang Strongtalk BabyJ Gradual Typing Saturday, November 19, 2011 12

  13. Optional Types Syntactically optional Do not a ff ect run-time semantics Saturday, November 19, 2011 13

  14. What does it look like? Saturday, November 19, 2011 14

  15. Mandatory Types: Pros In order of importance: Machine-checkable documentation Types provide conceptual framework Early error detection Performance advantages Saturday, November 19, 2011 15

  16. Mandatory Types: Cons Expressiveness curtailed Imposes work fl ow Brittleness Saturday, November 19, 2011 16

  17. Optional Types: Can we have our Cake and Eat it Too? Documentation (for humans and machines- but not veri fi able) Types provide conceptual framework Early error detection Performance advantages (much attenuated) Saturday, November 19, 2011 17

  18. Optional Typing Precludes ... Type-based overloading Type based initialization, e.g., int i; cannot mean var i: int = 0; Type classes, C# extension methods ... Saturday, November 19, 2011 18

  19. So what’s actually new? Didn’t we have all this in Strongtalk in 1993? Saturday, November 19, 2011 19

  20. Type Assertion Support Dart’s optional types are best thought of as a type assertion mechanism, not a static type system Saturday, November 19, 2011 20

  21. Dart Types at Runtime • During development one can choose to validate types • T x = o; assert(o === null || o is T); • By default, type annotations have no e ff ect and no cost • Code runs free Saturday, November 19, 2011 21

  22. Checked Mode Saturday, November 19, 2011 22

  23. Not your Grandfather’s Type System Not a type system at all - rather a static analysis tool based on heuristics, coupled to a type assertion mechanism Saturday, November 19, 2011 23

  24. What about a real, sound, type system? There is no privileged type system, but pluggable types are possible For example, one can write a tool that interprets existing type annotations strictly Saturday, November 19, 2011 24

  25. Runtime dependent on Type System Execution Type Checking Saturday, November 19, 2011 25

  26. Runtime Independent of Type System Execution Type Checking Saturday, November 19, 2011 26

  27. What about type inference? Type Inference relates to Type Checking as Type Checking to Execution Type inference best left to tools Saturday, November 19, 2011 27

  28. Type System dependent on Type Inference Type Checking Type Inference Saturday, November 19, 2011 28

  29. Type System Independent of Type Inference Type Checking Type Inference Saturday, November 19, 2011 29

  30. Don’t get Boxed-In Execution Type Checking Type Checking Type Inference Saturday, November 19, 2011 30

  31. Interfaces Every class induces an implicit interface Interfaces are rei fi ed at runtime Type tests are interface based You can implement the interface of another class without subclassing it Saturday, November 19, 2011 31

  32. Generics Rei fi ed Covariant subtyping Yes, Virginia, it isn’t sound Saturday, November 19, 2011 32

  33. Optional Types and Rei fi ed Types Annotations do not a ff ect semantics Type arguments to constructors? Interfaces? Saturday, November 19, 2011 33

  34. Optional Types and Rei fi ed Types Annotations do not a ff ect semantics Type arguments to constructors? Interfaces? Type Arguments to constructors are optional, but are rei fi ed Type tests are a dynamic construct that relies on rei fi ed interfaces Saturday, November 19, 2011 34

  35. Summary: Optional Types • Static checker provides warnings; tuned to be unobtrusive • Type annotations have no e ff ect except ... • During development, you can check dynamic types against declarations Saturday, November 19, 2011 35

  36. But is it Dynamic? noSuchMethod Mirrors & Debugging Saturday, November 19, 2011 36

  37. Some Modest Innovations Optional types ADTs without types Built-in Factory Support Saturday, November 19, 2011 37

  38. Libraries and ADTs A Library is a set of top-level classes, interfaces and functions Libraries may be be mutually recursive Libraries are units of encapsulation Saturday, November 19, 2011 38

  39. Libraries and ADTs Library based privacy - based on names - _foo is private to the library - naming and privacy are not orthogonal :-( - privacy can be recognized context-free :-) Saturday, November 19, 2011 39

  40. Interfaces vs. ADTs How to reconcile? - interfaces based on externally visible behavior - ADTs based on implementation Saturday, November 19, 2011 40

  41. Interfaces vs. ADTs What happens when we implement an interface with private members? // in library 1 class A { var _foo = 0;} foo(A a) => a._foo; // in library 2 class B implements A {int get _foo()=> 42;} foo(new B()); Saturday, November 19, 2011 41

  42. Interfaces vs. ADTs What happens when we implement an interface with private members? // in library 1 class A { var _foo = 0;} foo(A a) => a._foo // in library 2 class B implements A {int get _foo()=> 42;} // Warning? foo(new B()); Saturday, November 19, 2011 42

  43. Interfaces vs. ADTs What happens when we implement an interface with private members? // in library 1 class A { var _foo = 0;} foo(A a) => a._foo; // Warning? // in library 2 class B implements A {int get _foo()=> 42;} foo(new B()); Saturday, November 19, 2011 43

  44. Interfaces vs. ADTs class B implements A { int get _foo()=> 42; noSuchMethod(msg){ msg.name = ‘_foo’ ?msg.sendTo(this): super.noSuchMethod(msg); } } Saturday, November 19, 2011 44

  45. Some Modest Innovations Optional types ADTs without types Built-in Factory Support Saturday, November 19, 2011 45

  46. Factories Constructors without tears Use caches, return other types of objects Instance creation expressions based on interfaces Minimize need for Dependency Injection Saturday, November 19, 2011 46

  47. Factories Saturday, November 19, 2011 47

  48. Dart is not Done • Mixins? • Re fl ection • High level actor semantics: await? Erlang-style pattern matching? Promise-pipelining? • Class nesting? First class libraries? Non-nullable types? • Metadata? Pluggable types? Saturday, November 19, 2011 48

  49. Q & A Saturday, November 19, 2011 49

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend