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

Dart & Polymer - OSCON 2014

Dart & Polymer - OSCON 2014

Dart is one of the most interesting innovations to come from Google in recent years. It combines OO concepts with modern day web development and spits out JS code that can be run in any modern web browser as well as Dart byte code that can run on the DartVM.

It hides away all the bad parts in JS and gives you a clean, easy to understand platform to build powerful web applications.

Combined with Polymer, the framework to build components for the web, Dart makes itself the perfect platform for someone coming from a strong OO background to get started in web development.

In this session we will learn what Dart is all about, how you can build powerful web applications using Dart & Polymer and learn tips and tricks to speed up your Dart development.

We’ll go over the syntax, the tools, pitfalls, the language quirks, demo’s, examples and much much more.

By the end of the session, you’ll know enough to build a real world, production ready Dart app.

Faisal Abid

July 23, 2014
Tweet

More Decks by Faisal Abid

Other Decks in Programming

Transcript

  1. Who am I? ๏ Founder @ Dynamatik ๏ Co-Founder @

    Ember Chat ๏ Engineer @ Kobo ๏ @FaisalAbid ๏ [email protected] - Ask me anything about Node, AngularJS, Dart, Polymer, and Android.
  2. About the talk ๏ Split into three parts. ๏ For

    someone who has not done Dart and Polymer before. ๏ Goal is to inspire you to go out, learn Dart & Polymer and rule the world. ๏ Part 1. Dart introduction to basic language concepts ๏ Part 2. Quick rundown of Web components & Polymer ๏ Part 3. Dart + Polymer and how they love each other
  3. What is Dart & Why should I care? ๏ Dart

    is a new platform and language by Google. ๏ Dart is for “Scalable web app engineering”
  4. Scalable web app engineering ๏ Javascript is “Scalable” to an

    extent • RequireJS/AMD modules • Frameworks like Backbone, Ember.js, Angular.js • JQuery, Zepto
  5. Javascript is the root of all evil* *a little bit

    dramatic, but gets the point across
  6. Scalable web app engineering ๏ Dart is built for scale

    • Optional type checking - I <3 typed objects • Single threaded “Isolate” concept for server apps. Web workers for client. • Objects, Classes, Polymorphism • Easy async, less messy callbacks • Many years of programming language research • High performance VM, Dartium • Compile straight to JS for cross browser compatibility
  7. All while keeping the language easy to develop in. Because

    all that scale stuff is cool, but this is what really matters.
  8. class Conference { String name; num attendees; Conference(String name, num

    attendees) { this.name = name; this.attendees = attendees; } } // then later var OSCON = new Conference("OSCON", 5800); Example Class in Dart
  9. OOP ๏ Dart is Object Oriented. ๏ Makes web development

    sane. ๏ Concept of libraries to pair multiple classes together. ๏ One .dart file can have multiple classes.
  10. OOP - summary ๏ Part / Part of makes easy

    to separate “libraries” ๏ Constructors can easily set instance variables ๏ Control visibility with _ ๏ Easy one line methods with => ๏ Listen to events with .listen
  11. Optionally Typed ๏ Dart is optionally typed. ๏ For Public

    API’s / Public Methods - Use Type ๏ For internal method implementations, use var. • Dart IDE will make use of type info also. Easy code assist. • “Explicit type annotations are usually just visual noise.”
  12. Async / Future ๏ One of the most powerful features

    of Dart ๏ Dart is single threaded, blocking code blocks! ๏ Dart futures lets you perform async operations. I.e HTTP
  13. Async / Future - Recap ๏ One of the most

    powerful features of Dart ๏ Dart is single threaded, blocking code blocks! ๏ Dart futures lets you perform async operations. I.e HTTP ๏ Futures make it easy to avoid callback hell and keep syntax simple. ๏ Almost one line API calls. no callbacks needed
  14. Dart Everywhere ๏ You can write your Dart apps on

    the server side also! ๏ Dart on the full stack! Front-end and backend. ๏ Use classes, futures and everything you’ve learned
  15. Dart for web ๏ Ran through simple but powerful examples.

    ๏ Dart makes web development easy. ๏ Dart is built to scale, with OOP principals, Async programming made easy and simple to use syntax. Making Dart web apps is easy. ๏ But what’s this polymer thing about?
  16. What are web components? ๏ Next generation of encapsulation for

    the web. ๏ Build your own tag, hide the implementation details.
  17. Whats the shadow DOM? ๏ Shadow DOM hides the web

    component implementation from the DOM. ๏ I.e <my-tag> shows up as <my-tag> and not a series of divs. ๏ Ready in firefox, chrome, opera, and their mobile counterparts. ๏ Not in Safari. ๏ Polyfills ready for older browsers and Safari. Mileage may vary
  18. Now what’s Polymer then? ๏ Truthfully the web component spec

    is sometimes messy ๏ Hard to implement on its own. ๏ Polymer wraps all this up in a nice abstraction layer. By Google ๏ Works wherever Web components/ Shadow dom works.
  19. Can I use Polymer with only Dart? ๏ No! Polymer

    can be used with Javascript. In fact it’s first written for JS. ๏ Dart has a feature parity port by Google. ๏ pub : polymer ๏ pub : paper-elements ๏ Polymer is better with Dart. You feel like you are coding for the future.
  20. How do you use Polymer with Dart ๏ Starter project

    makes it easy to get started. ๏ Transformer gets polymer all ready to rock.
  21. Simple data binding in Polymer ๏ You want your components

    to do something and take attributes ๏ Databinding is simple with polymer. ๏ Lets take a look!
  22. Simple data binding in Polymer ๏ You want your components

    to do something and take attributes ๏ Databinding is simple with polymer. ๏ @published - is two way binding ๏ @observable - is one way binding
  23. ! @CustomTag(‘speaker-list') class SpeakerList extends PolymerElement { final List speakers

    = toObservable(["Speaker One", "Speaker Two", "Speaker Three"]); ! SpeakerList() : super.created(); } ! [ . . . ] ! <template repeat=“{{speaker in speakers}}”> <li> {{speaker}} </li> </template> Example list data binding in Dart
  24. Material Design & Polymer ๏ Google introduced this at Google

    IO ๏ Sexy fluid new UI components for the web & mobile. ๏ “Paper-elements” is a package ready to be used by Dart. In fact many examples have used paper-elements already!
  25. Closing Thoughts ๏ Dart is ready for prime time. version

    1.5.2 ๏ Polymer still in beta for Dart, but “pretty” stable. ๏ Dart brings sanity to web development. ๏ Polymer/Web components brings proper modularity to web development. ๏ Dart is moving full steam ahead, adopted heavily by Google. ๏ It’s not going anywhere, so embrace change and lets rule the world.
  26. Thank you @FaisalAbid - [email protected] Title screen by Sam Beck

    - two-thirty.tumblr.com Thanks to cloudimage.io for helping me out with my Image CDN needs. Check them out!