Wednesday, July 24, 2013

OSCON 10 Reasons You'll Love Dart

The 10 Reasons You'll Love Dart page on OSCON site.

Chris Strom (EEE Computes)
11:30am Wednesday, 07/24/2013

Compiles to JavaScript.
Attempts to normalize the compiled code for all browsers.
All browsers supported but for IE 10+

A language that doesn't affect the way you think about programing, is not worth know. Alan Perlis

primer on functions in Dart:
say_hi(name) {
      return "hi, ${name}";


Must have ; at end of statement in Dart, in JS this is optional

syntactic sugar for above:
say_hi(name) => "hi, ${name}";

anon functions:
var say_hi = (name) => "hi...

magic instance variables:
class Cookie {
   var num;
   Cookie(number) {
      num = number;

Also, quick assignment in constructor:

precede the variable name in the class with an _ to make that variable private and inaccessible from outside the class.

get and set are Dart keywords used for getters and setters of private _ variables.

parameters can be optional, named, required and default

Method cascades (i.e. fluent syntax):

Can be used for setting methods, e.g. in CSS:
   ..position = 'absolute'

Unit Tests
- built into language
test_create() {
   group("new DBs", () {

test("creates a new DB", () {

Client-side libraries, declare:
library cookies;

import 'dart:html';
import 'cookie.dart';

Pub packages:
pub install
- pulls in dependencies

class Cookie extends HipsterModel {
   Cookie(attributes) :

public git repos
great for local dev

Statically Typed Language
class Cookie {
   int num;
You can assign a string to an int and it will compile and run. However, if your run dartanalyzer then it will pick up your intention and complain. Can put this into the build process. Dart editor has this built in.

Tools to generate HTML about code.
Accepts /// for comments to be extracted into the documentation.
Client side search in docs

Chris Strom @eee_c does a #pairwithme!!! on Tuesdays at 7:30pm PST.

No comments:

Post a Comment