Download - Introduction to Dart
![Page 1: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/1.jpg)
#flydart #gdgac
Welcome
![Page 2: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/2.jpg)
#flydart #gdgac
![Page 3: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/3.jpg)
#flydart #gdgac
Introduction to
Based on the Slides by Seth Ladd
![Page 4: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/4.jpg)
#flydart #gdgac
Who am I?
Sebastian MauerGDG Aachen Co-Lead CS Student
Software Engineer I don’t work for Google …yet
aka
![Page 5: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/5.jpg)
#flydart #gdgac
![Page 6: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/6.jpg)
#flydart #gdgac
✔ Improved productivity ✔ Increased performance
is about two things:
![Page 7: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/7.jpg)
#flydart #gdgac
Learn the language in under one hour.(we have the whole day)
![Page 8: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/8.jpg)
#flydart #gdgac
Use the tools you already know
IntelliJ Sublime
Eclipse (DartEditor)
![Page 9: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/9.jpg)
#flydart #gdgac
Compile to JavaScript(runs across the modern web)
![Page 10: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/10.jpg)
#flydart #gdgac
Run Dart on the server with the Dart VM
![Page 11: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/11.jpg)
#flydart #gdgac
require.js
Backbone
Backbone Marionette
jQuery
Modernizr
moment.js
dest templates
PhantomJS
JasmineDocs
Docs
Docs
Docs
Docs
Docs
Docs
Docs
Docs
![Page 12: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/12.jpg)
#flydart #gdgac
Clear and consistent
Unit test
Dart SDK
Polymer
Intl
Pac
kag
es
![Page 13: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/13.jpg)
#flydart #gdgac
Apps start small, but grow and scale
![Page 14: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/14.jpg)
#flydart #gdgac
Simple syntax, ceremony freeclass Hug { Familiar
![Page 15: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/15.jpg)
#flydart #gdgac
Simple syntax, ceremony freeclass Hug { num strength; Hug(this.strength); Terse
![Page 16: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/16.jpg)
#flydart #gdgac
Simple syntax, ceremony freeclass Hug { num strength; Hug(this.strength); !Hug operator +(Hug other) { return new Hug(strength + other.strength); }
Operator overriding
![Page 17: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/17.jpg)
#flydart #gdgac
Simple syntax, ceremony freeclass Hug { num strength; Hug(this.strength); !Hug operator +(Hug other) { return new Hug(strength + other.strength); } !void patBack({int hands: 1}) { // ... }
Named, optional params w/ default value
![Page 18: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/18.jpg)
#flydart #gdgac
Simple syntax, ceremony free… Hug operator +(Hug other) { return new Hug(strength + other.strength); } !void patBack({int hands: 1}) { // ... } !String toString() => "Embraceometer reads $strength";
One-line Function
![Page 19: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/19.jpg)
#flydart #gdgac
Simple syntax, ceremony free… Hug operator +(Hug other) { return new Hug(strength + other.strength); } !void patBack({int hands: 1}) { // ... } !String toString() => "Embraceometer reads $strength";
String interpolation
![Page 20: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/20.jpg)
#flydart #gdgac
![Page 21: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/21.jpg)
#flydart #gdgac
![Page 22: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/22.jpg)
#flydart #gdgac
Clean semantics and behavior
• Only true is truthy
• There is no undefined, only null
• No type coercion with ==, +
Examples
![Page 23: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/23.jpg)
#flydart #gdgac
Clean semantics and behavior
"hello".missing // ??
Class 'String' has no instance getter 'missing'NoSuchMethodError : method not found: ‚missing'Receiver: "hello"Arguments: []
LOGICAL!
![Page 24: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/24.jpg)
#flydart #gdgac
Clean semantics and behavior
'hello' > 1 // ??Class 'String' has no instance method '>'.
LOGICAL!
![Page 25: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/25.jpg)
#flydart #gdgac
Clean semantics and behavior
var foo = 'top-level'; !main() { if (true) { var foo = 'inside'; } ! print(foo); // ?? What will this print? }
LOGICAL!
Variable scope?
NO HOISTING!top-level
![Page 26: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/26.jpg)
#flydart #gdgac
Clean semantics and behavior
class AwesomeButton { ! AwesomeButton(button) { button.onClick.listen((Event e) => this.atomicDinosaurRock()); } ! atomicDinosaurRock() { /* ... */ } }
LOGICAL!
Scope of „this“?
LEXICAL THIS!
![Page 27: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/27.jpg)
#flydart #gdgac
Scalable Structure
Functions Classes
Libraries
Packages
Mixins Interfaces
library games; !import 'dart:math'; import 'players.dart'; !class Darts { // ... } !class Bowling { // ... } !Player findOpponent(int skillLevel) { // ... }
![Page 28: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/28.jpg)
#flydart #gdgac
Too many Buttonsvar button = new ButtonElement(); button.id = 'fancy'; button.text = 'Click Point'; button.classes.add('important'); button.onClick.listen((e) => addTopHat()); !parentElement.children.add(button);
![Page 29: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/29.jpg)
#flydart #gdgac
Method cascadesvar button = new ButtonElement() ..id = 'fancy' ..text = 'Click Point' ..classes.add('important') ..onClick.listen((e) => addTopHat()); !parentElement.children.add(button);
![Page 30: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/30.jpg)
#flydart #gdgac
Inline initialization
parentElement.children.add( new ButtonElement()..text = 'Click Point');
![Page 31: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/31.jpg)
#flydart #gdgac
One of these things is not like the other
Object
Persistable
Hug
Hug is not a is-a Persistable
Don’t pollute your inheritance tree!
![Page 32: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/32.jpg)
#flydart #gdgac
Don’t inherit, mixin!
Object
Hug Mixin Persistable
![Page 33: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/33.jpg)
#flydart #gdgac
Mixinsabstract class Persistable { save() { ... } load() { ... } toJson(); } !class Hug extends Object with Persistable { Map toJson() => {'strength':10}; } !main() { var embrace = new Hug(); embrace.save(); }
Extend object & no constructors? You can
be a mixin!
Apply the Mixin
Use Methods from the Mixin
![Page 34: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/34.jpg)
#flydart #gdgac
![Page 35: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/35.jpg)
#flydart #gdgac
pub
• A package manager
• Integrated right from the start
• 670+ packages
![Page 36: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/36.jpg)
#flydart #gdgac
Dart. Right now.
• dart2js compiles Dart to JavaScript
• at least until the DartVM isavailable within all platforms
![Page 37: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/37.jpg)
#flydart #gdgac
Ready to get started? Write a Dart app!
(after a short break)
![Page 38: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/38.jpg)
#flydart #gdgac
Codelab
![Page 39: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/39.jpg)
#flydart #gdgac
Codelab
![Page 40: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/40.jpg)
#flydart #gdgac
Hackathon
![Page 41: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/41.jpg)
#flydart #gdgac
Hackathon Winners
![Page 42: Introduction to Dart](https://reader038.vdocuments.us/reader038/viewer/2022102711/554fb7abb4c9053d018b458e/html5/thumbnails/42.jpg)
#flydart #gdgac
Please fill out the evaluation form