Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Structured Web Apps with Google Dart

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Structured Web Apps with Google Dart

An introduction to the Dart platform for modern web app development.

Avatar for Jermaine Oppong

Jermaine Oppong

August 21, 2014

Other Decks in Programming

Transcript

  1. AGENDA ►  What is Dart? ►  How Dart Works ► 

    Dart Features ►  Language Tour ►  CASE DEMOS ►  Questions
  2. BY GOOGLE Gilad Bracha Software Engineer Lars Bak Computer Programmer

    ►  HotSpot  VM   ►  V8  JavaScript  Engine   ►  Dart  VM   ►  Newspeak  Language   ►  Java  Language  Spec   ►  Dart  Language  Spec  
  3. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS
  4. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery
  5. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...”
  6. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS
  7. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr
  8. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI
  9. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI Leaflet.JS
  10. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI Leaflet.JS Jasmine BDD
  11. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI Leaflet.JS Jasmine BDD Raphael.JS
  12. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI Leaflet.JS Jasmine BDD Raphael.JS DOCS DOCS DOCS DOCS DOCS DOCS DOCS DOCS DOCS
  13. “Hey, I want a web app” Backbone.JS “Backbone’s only hard

    dependency is Underscore.js” Underscore.JS jQuery “For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include jQuery...” Moment.JS Modernizr jQueryUI Leaflet.JS Jasmine BDD Raphael.JS DOCS DOCS DOCS DOCS DOCS DOCS DOCS DOCS DOCS
  14. DART BUNDLE IDE Dartium Dart SDK ►  Eclipse-based editor ► 

    Supports code completion, static analysis, Checked/ Production Mode etc… ►  Plugins for third-party IDE and Text-Editors    
  15. DART BUNDLE IDE Dartium Dart SDK ►  Eclipse-based editor ► 

    Supports code completion, static analysis, Checked/ Production Mode etc… ►  Plugins for third-party IDE and Text-Editors ►  Custom build of Chromium with the Dart VM    
  16. DART BUNDLE     IDE Dartium Dart SDK ►  Eclipse-based

    editor ►  Supports code completion, static analysis, Checked/ Production Mode etc… ►  Plugins for third-party IDE and Text-Editors ►  Custom build of Chromium with the Dart VM ►  Dart VM, Core Libraries and Command line tools
  17. TREE-SHAKING COMPILER main   Library fn()   fn()   fn()

      fn()   Source Application imports
  18. TREE-SHAKING COMPILER main   Library fn()   fn()   fn()

      fn()   Source Application calls imports
  19. TREE-SHAKING COMPILER main   Library fn()   fn()   fn()

      fn()   Source Application calls calls imports
  20. TREE-SHAKING COMPILER main   Library fn()   fn()   fn()

      fn()   Source Application calls calls imports dart2js
  21. TREE-SHAKING COMPILER main   Library fn()   fn()   fn()

      fn()   Source Application calls calls imports main   fn()   fn()   calls calls dart2js
  22. ►  Object-oriented language ►  Single-threaded ►  Asynchronous Programming with Futures/Streams

    ►  Concurrency with Isolates ►  Lexical Scoping ►  Modularity and Scalability
  23. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth);!

    }! ! void main() {! !Person person = new Person(“Joe Bloggs”, 1975);! !print(person.name);! }! !!
  24. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth);!

    }! ! void main() {! !Person person = new Person(“Joe Bloggs”, 1975);! !print(person.name);! }! !! Shorthand Constructors
  25. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth);!

    !Person.withDefaults() : this(‘No name’, 1768);! }! ! void main() {! !Person person = new Person.withDefaults();! !print(person.name);! }! !! Named Constructors
  26. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth);!

    !Person.withDefaults() : this(‘No name’, 1768);! }! ! void main() {! !Person person = new Person.withDefaults();! !print(person.name);! }! !! Initialised defaults
  27. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth,

    {String nationality: ‘unknown’});! !Person.withDefaults() : this(‘No name’, 1768);! }! ! void main() {! !Person person = new Person(“Joe Bloggs”, 1975, nationality: ‘UK’);! !print(person.name);! }! !! Optional named parameters
  28. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth,

    [String nationality = ‘unknown’]);! !Person.withDefaults() : this(‘No name’, 1768);! }! ! void main() {! !Person person = new Person(“Joe Bloggs”, 1975, ‘UK’);! !print(person.name);! }! !! Optional positional parameters
  29. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth,

    [String nationality = ‘unknown’]);! !Person.withDefaults() : this(‘No name’, 1768);! !! !Person operator +(Person other) {! ! !return new Person(name + ‘ and ‘ + other.name, 9999);! !}! } !! Operator overrides
  30. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth,

    [String nationality = ‘unknown’]);! !Person.withDefaults() : this(‘No name’, 1768);! !! !Person operator +(Person other) {! ! !return new Person(name + ‘ and ‘ + other.name, 9999);! !}! ! !speak() => print(“$name is speaking”);! } !! Shorthand functions
  31. class Person {! !String name;! !int yearOfBirth;! ! !Person(this.name, this.yearOfBirth,

    [String nationality = ‘unknown’]);! !Person.withDefaults() : this(‘No name’, 1768);! !! !Person operator +(Person other) {! ! !return new Person(name + ‘ and ‘ + other.name, 9999);! !}! ! !speak() => print(“$name is speaking”);! } !! String interpolation
  32. class Person {! !String _name;! !int _yearOfBirth;! ! !Person(this._name, this._yearOfBirth);!

    !Person.withDefaults() : this(‘No name’, 1768);! ! !Person operator +(Person other) {! ! !return new Person(name + ‘ and ‘ + other.name, 9999);! !}! ! !speak() => print(“$_name is speaking”);! ! !String get name => _name;! ! set name(String value) => _name = value;! } !! getters and setters
  33. import “dart:html”;! ! void main() {! !! !InputElement button =

    new InputElement();! ! ! ! !button.id = “sendButton”;! ! ! ! !button.text = “Donate Bruv!!!”;! ! ! ! !button.classes.add(‘please’);! ! ! ! !button.onClick.listen((e) => print(‘thanks!’));! ! !document.body.children.add(button);! ! ! ! ! ! } !!
  34. import “dart:html”;! ! void main() {! !! !InputElement button =

    new InputElement();! ! ! ! !button.id = “sendButton”;! ! ! ! !button.text = “Donate Bruv!!!”;! ! ! ! !button.classes.add(‘please’);! ! ! ! !button.onClick.listen((e) => print(‘thanks!’));! ! !document.body.children.add(button);! ! ! ! ! ! } !!
  35. import “dart:html”;! ! void main() {! !! !InputElement button =

    new InputElement()! ! ! ! !..id = “sendButton”! ! ! ! !..text = “Donate Bruv!!!”! ! ! ! !..classes.add(‘please’)! ! ! ! !..onClick.listen((e) => print(‘thanks!’));! ! !document.body.children.add(button);! ! ! ! ! ! } !! Method Cascades
  36. class Person {! !String name;! !int yearOfBirth;! ! !Person({this.name, this.yearOfBirth});!

    ! !speak() => print(“$name is speaking”);! }! ! void main() {! !Person person = new Person()! ! ! ! !..name = “Joe Bloggs”! ! ! ! !..yearOfBirth = 1985! ! ! ! !..speak();! ! !print(person.name);! }! !!
  37. class Person {! !speak() => print(“person is speaking”);! }! !

    class Customer extends Person {! !String _name;! !Customer(this._name);! }! !!
  38. class Person {! !speak() => print(“person is speaking”);! }! !

    class VIPPermissions extends Person {! !luxuryTreatment() => print(“Your royal suite is ready!”);! }! ! class Customer extends VIPPermissions {! !String _name;! !Customer(this._name);! }! !!
  39. class Person {! !speak() => print(“person is speaking”);! }! !

    class VIPPermissions extends Person {! !luxuryTreatment() => print(“Your royal suite is ready!”);! }! ! class Customer extends VIPPermissions {! !String _name;! !Customer(this._name);! }! !! Customer  IS   NOT  a   VIPPermissions !!!  
  40. abstract class VIPPermissions {! !luxuryTreatment() => print(“Your royal suite is

    ready!”);! }! ! class Person {! !speak() => print(“person is speaking”);! }! ! class Customer extends Person with VIPPermissions {! !String _name;! !Customer(this._name);! }! !!
  41. abstract class VIPPermissions {! !luxuryTreatment() => print(“Your royal suite is

    ready!”);! }! ! class Person {! !speak() => print(“person is speaking”);! }! ! class Customer extends Person with VIPPermissions {! !String _name;! !Customer(this._name);! }! ! void main() {! !Customer customer = new Customer(‘Charles’)..luxuryTreatment();! }! !!
  42. abstract class VIPPermissions {! !luxuryTreatment() => print(“Your royal suite is

    ready!”);! }! ! class Person {! !speak() => print(“person is speaking”);! }! ! class Customer extends Person with VIPPermissions {! !String _name;! !Customer(this._name);! }! ! void main() {! !Customer customer = new Customer(‘Charles’)..luxuryTreatment();! }! !!
  43. BUT THAT’S NOT ALL! ►  Generics ►  Mirrors/Reflections ►  Transformations

    ►  Metadata/ Annotations ►  Factories ►  Lazy-loading ►  Interoperate with JS ►  Observatory ►  Automatic Sanitization ►  Web Components ►  SIMD ►  and lots more…