Bullseye: An introduction to Dart

Db6218c1b56d64e775eb79ea4f2889dd?s=47 Sebastian
October 29, 2016

Bullseye: An introduction to Dart

Let's dive into the language straight. You do not need any knowledge of the language prior to this. I'll walk through language features with the example!

This talk was given at the Webcamp Zagreb 2016

Db6218c1b56d64e775eb79ea4f2889dd?s=128

Sebastian

October 29, 2016
Tweet

Transcript

  1. Bullseye: An introduction to Dart Webcamp Zagreb 2016 @Sgoettschkes https://static.pexels.com/photos/21300/pexels-photo.jpg

  2. “So any team considering Angular2 should consider Dart as well.”

    Joshy Joseph, Google Adwords http://news.dartlang.org/2016/03/the-new-adwords-ui-uses-dart-we-asked.html
  3. None
  4. Why Dart? https://static.pexels.com/photos/59628/pexels-photo-59628.jpeg

  5. Why Dart? • A consistent language • Great standard library

    • Batteries included • General purpose language
  6. A consistent language • Everything is an object • Optional

    static types • Async/Await • Library system
  7. Great standard library • dart:core • dart:async • dart:math •

    dart:html or dart:io • dart:convert
  8. Batteries included • dart: The interpreter • pub: Package manager

    • dartfmt: Opinionated formatter • dartanalyzer: Static code analyzer • dart2js: Transpiler • ...
  9. General purpose language • Client-Side (AngularDart / PolymerDart) • Server-Side

    (rpc / redstone) • Mobile (fluffer) • ...
  10. Why not? • A new language to learn • Hard

    to find experts • Moving target • Small community
  11. Language Features https://www.dropbox.com/s/tfrndnh2i883wbs/289H.jpg?dl=1

  12. Optional types String name = ‘Sebastian’; var firstName = ‘Sebastian’;

    assert(name == firstName);
  13. Optional types String name = ‘Sebastian’; var firstName = ‘Sebastian’;

    assert(name == firstName); String fullName(String firstName, var lastName) { return firstName + ‘ ‘ + lastName; }
  14. Function arguments String test(String arg1, [String arg2]) { // ...

    } test(‘s1’); test(‘s1’, ‘s2’);
  15. Function arguments String test(String arg1, [String arg2]) { // ...

    } test(‘s1’); test(‘s1’, ‘s2’); String test2(String arg1, {String arg2}) { // ... } test2(‘s1’); test2(‘s1’, arg2: ‘s2’);
  16. Constructors class User { String firstName; int age; User(this.firstName, this.age);

    }
  17. Constructors class User2 { String firstName; int age; User2(String firstName,

    int age){ this.firstName = firstName; this.age = age; } }
  18. Implicit Getters/Setters User sebastian = new User(‘Sebastian’, 29); print(sebastian.firstName); //

    Output: ‘Sebastian’ sebastian.age = 32; print(sebastian.age); // Output: ‘32’
  19. Implicit Getters/Setters class User { String _firstName; // private property

    int _age; // private property String get firstName { return _firstName; } void set age(age) { _age = age < 21 ? 0 : age; } }
  20. Implicit Getters/Setters User sebastian = new User(‘Sebastian’, 29); print(sebastian.firstName); //

    Output: ‘Sebastian’ sebastian.age = 32; print(sebastian.age); // Error!
  21. Exceptions void letMeFail() { throw ‘This is my error message’;

    }
  22. Exceptions void letMeFail() { throw ‘This is my error message’;

    } try { letMeFail(); } on String catch s { print(s); } catch() { print(‘Generic Exception’); }
  23. String interpolation String fullName(firstName, lastName) { return ‘${firstName} ${lastName}’; }

  24. String interpolation String fullName(firstName, lastName) { return ‘${firstName} ${lastName}’; }

    print(‘${fullName(‘Sebastian’, ’Göttschkes’)}’);
  25. Async / Await doSomething() async { await longTask(); // ...

    }
  26. Async / Await doSomething() async { await longTask(); // ...

    } doSomething2() { longTask().then(() { // … }); }
  27. But what about ...

  28. http://pixabay.com/static/uploads/photo/2010/12/10/08/salad-1105_640.jpg

  29. None
  30. None
  31. “So any team considering Angular2 should consider Dart as well.”

    Joshy Joseph, Google Adwords http://news.dartlang.org/2016/03/the-new-adwords-ui-uses-dart-we-asked.html
  32. https://www.dropbox.com/s/6z5aiwa8l09g2pa/86H.jpg

  33. https://joind.in/talk/3c5ab