small medium large xlarge

Dart 1 for Everyone: Fast, Flexible, Structured Code for the Modern Web


Cover image for Dart 1 for Everyone
Pages 164
Release P1.0 (2014-11-11)
ISBN 978-1-94122-225-6

Psst! You’re not stuck with JavaScript anymore. Google’s Dart language makes programming for the Web simpler, faster, and more powerful. With version 1.0 in 2013 and an ECMA standard in 2014, Dart is ready to radically change web development for the better. And Dart 1 for Everyone has got you covered. Completely updated for Dart 1 and the ECMA standard, with new sections on new Dart features like method cascades, event streams, and class constructor syntax, this book wastes no time in immersing you in the finer points of this powerful and surprisingly beautiful language.

The first edition of this book was released as Dart for Hipsters.

Choose Your Format(s)
  • $30.00 In Stock

    Save $9.00 on the combo pack.

  • $24.00 In Stock
  • $15.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About This Title

This BookBeginnerExpert

Dart has changed significantly since the first printing of this book and Dart 1 for Everyone has kept up. Every chapter has been revised and some chapters have been almost completely rewritten since the first printing. The MVC project chapters dumped the old JavaScript-like event handlers for the sleek new streams interface, and the chapter on testing reflects the extensive changes in testing now available in Dart.

Brand-new sections explore some of Dart’s beautiful new features, such as:

  • Method cascades: Improve code readability dramatically.
  • Event streams: Simplified event handling, consistent with virtually every other asynchronous interaction in Dart.
  • Library parts: Yet another way Dart promotes code organization.
  • New class constructor syntax: Dart supports a nice variety of surprisingly expressive and concise ways to declare constructors.
  • Building your own packages: Quickly share your work with the world.

You’ll start writing Dart code on page 1, and throughout the book, you’ll refactor that code to explore Dart’s features: OOP, real libraries and packages, testing, and more. You’ll learn how to write beautiful, maintainable application code that just works™ in all modern browsers. Caution: after reading you may develop an intense attachment to structured code and skinny jeans.

Read the reviews .

You Might Also Like

  • Cover Image For Seven More Languages in Seven Weeks…
  • Cover Image For Building Backbone Plugins…
  • Cover Image For Automate with Grunt…
  • Cover Image For Seven Web Frameworks in Seven Weeks…
  • Cover Image For Node.js the Right Way…
  • Cover Image For HTML5 and CSS3…

What You Need

You will need the Dart SDK, which is freely available from Most of the book works with Dartium, a preview release of Chrome that is included in the SDK and has the Dart VM built-in. Some of the examples use either the dart2js tool or the Dart Editor to compile Dart down into JavaScript—both are part of the SDK.

5 Things You Don’t Know About Dart

5. It has brilliant server and browser package management. The “Pub” package manager works the same whether you are writing server code or a web application. List your dependencies in a pubspec.yaml file, run “pub get”, and your dependencies (and their dependencies) are immediately available. Whether it is compiled to JavaScript or run natively in the browser, Dart’s libraries and packages make organizing code a breeze.

4. It’s not really statically typed. You can declare variables with or without types—it makes no difference whatsoever at runtime. If you like declaring variables with var, go right ahead. If you like documenting code with types, feel free (it’ll help with docs and code analysis tools).

3. It has beautiful unit (and acceptance) testing built into the language from the outset. To build bulletproof applications, you need a strong testing suite. And Dart has you covered. Brilliantly.

2. Dart does not compile directly to JavaScript. To support all modern browsers (even IE10+), dart2js compiles to a JavaScript compatibility layer. That JavaScript compatibility layer is quite large, so dart2js performs sophisticated tree shaking so that it can drop unused bits, keeping the compiled code and compatibility layer as small as possible. The Dart team works hard to ensure that this compatibility layer works across the modern web so you don’t have to. No more browser checking. No more weird browser-specific bugs. Your code just works. Everywhere.

1. It rivals Ruby for code beauty. In addition to its simple, classical inheritance, Dart is loaded with syntactic sugar to make a programmer’s life easier. To name just a few, Dart has:

  • Method cascades (calling multiple methods on the same object).
  • First-class support for optional parameters (no more parsing an options hash, yay!)
  • Getter and setter methods (methods that look like properties, but are backed by a normal method).
  • Assignment of instance variables in the constructor declaration instead of the body.
  • String interpolation—no more chains of plus signs!

It’s the little things really. And Dart has so many little things that add up to greatness.

0. (BONUS!) It is fast. In many cases, the compiled JavaScript is faster than the JavaScript that you can hand-code. Don’t believe me? Check out the benchmarks and try it yourself!


Each of our books has its own dedicated discussion area, where readers help each other out. Many authors also choose to drop by.

Join in…

Here are some recent topics:

Contents & Extracts

  • Introduction
  • Getting Started
    • Project: Your First Dart Application
      • The Back End
      • HTML for Dart
      • Ajax in Dart
      • This App Won’t Run
      • What’s Next
    • Basic Types
      • Numbers
      • Strings
      • Booleans
      • Maps (aka Hashes, Associative Arrays)
      • Lists (aka Arrays)
      • Dates
      • Types
      • What’s Next
    • Functional Programming in Dart
      • Anonymous Functions
      • First-Order Functions
      • Optional Arguments
      • What’s Next
    • Manipulating the DOM
      • dart:html
      • Finding Things
      • Adding Things
      • Removing Things
      • Updating Elements
      • Method Cascades
      • DOM Ready
      • What’s Next
    • Dart and JavaScript
      • Compiling to JavaScript with dart2js
      • Maintaining Dart and JavaScript Side-by-Side
      • Using JavaScript in Dart
      • What’s Next
  • Effective Coding Techniques
    • Project: MVC in Dart
      • MVC in Dart
      • Hipster Collections
      • Hipster Models
      • Hipster Views
      • Putting Models, Collections, and Views Together to Create New Records
      • What’s Next
    • Classes and Objects
      • Class Is a First-Order Concept
      • Instance Variables
      • Methods
      • Static Methods and Variables (aka Class Methods and Variables)
      • Subclasses
      • Duck-Typing in Dart with implements
      • Mixins
      • Constructors
      • What’s Next
    • Events and Streams
      • Plain-Old Events
      • Making Custom Events with Streams
      • What’s Next
  • Code Organization
    • Project: Extracting Libraries
      • What to Extract and What to Leave
      • Real Libraries
      • What’s Next
    • Libraries
      • Parts
      • Libraries
      • Core Dart Libraries
      • Packaging with “pub”
      • What’s Next
  • Maintainability
    • Project: Varying Behavior
      • Vary Class Behavior with noSuchMethod()
      • Sync Through Dependency Injection
      • What’s Next
    • Testing Dart
      • Obtaining the Test Harness
      • 2 + 2 = 5 Should Be Red
      • What’s Next
  • The Next Level with Dart
    • Project: An End to Callback Hell
      • The Future
      • Handling Errors in the Future
      • What’s Next
    • Futures and Isolates
      • Completers and Futures
      • Isolates
      • What’s Next
    • HTML5 and Dart
      • Animation
      • Local Storage
      • WebSockets
      • Canvas
      • Wrapping Up

Brought to You By

Chris Strom is a relentless public learner, with more than 1,500 blog posts serving as research notes for his books. He has more than 10 years experience programming in Perl, Ruby, JavaScript, or whatever his current obsession happens to be. Chris lives in Baltimore, MD with his wife, 4 children, and a goldfish named Martin Tanner.