You are previewing The Dart Programming Language.
O'Reilly logo
The Dart Programming Language

Book Description

Dart is a class-based, object-oriented language that simplifies the development of structured modern apps, scales from small scripts to large applications, and can be compiled to JavaScript for use in any modern browser. In this rigorous but readable introductory text, Dart specification lead Gilad Bracha fully explains both the language and the ideas that have shaped it.

The Dart Programming Language offers an authoritative description of Dart for programmers, computer science students, and other well-qualified professionals. The text illuminates key programming constructs with significant examples, focusing on principles of the language, such as optional typing and pure object-orientation.

Bracha thoroughly explains reflection in Dart, showing how it is evolving into a form that programmers can easily apply without creating excessively large programs. He also shares valuable insights into Dart’s actor-style model for concurrency and asynchronous programming. Throughout, he covers both language semantics and the rationale for key features, helping you understand not just what Dart does, but why it works the way it does.

You will learn about

  • Dart’s object model, in which everything is an object, even numbers and Boolean values

  • How Dart programs are organized into modular libraries

  • How Dart functions are structured, stored in variables, passed as parameters, and returned as results

  • Dart’s innovative approach to optional typing

  • How Dart handles expressions and statements

  • How to use Dart’s implementation of reflection to introspect on libraries, classes, functions, and objects

  • Isolates and other Dart features that support concurrency and distribution

  • Register your product at informit.com/register for convenient access to downloads, updates, and corrections as they become available.

    Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents
    6. Foreword
    7. Preface
    8. Acknowledgments
    9. About the Author
    10. Chapter 1. Introduction
      1. 1.1 Motivation
      2. 1.2 Design Principles
        1. 1.2.1 Everything Is an Object
        2. 1.2.2 Program to an Interface, not an Implementation
        3. 1.2.3 Types in the Service of the Programmer
      3. 1.3 Constraints
      4. 1.4 Overview
      5. 1.5 Book Structure
      6. 1.6 Related Work and Influences
    11. Chapter 2. Objects, Interfaces, Classes and Mixins
      1. 2.1 Accessors
      2. 2.2 Instance Variables
      3. 2.3 Class Variables
      4. 2.4 Finals
      5. 2.5 Identity and Equality
      6. 2.6 Class and Superclass
      7. 2.7 Abstract Methods and Classes
      8. 2.8 Interfaces
      9. 2.9 Life of an Object
        1. 2.9.1 Redirecting Constructors
        2. 2.9.2 Factories
      10. 2.10 noSuchMethod()
      11. 2.11 Constant Objects and Fields
      12. 2.12 Class Methods
      13. 2.13 Instances, Their Classes and Metaclasses
      14. 2.14 Object and Its Methods
      15. 2.15 Mixins
        1. 2.15.1 Example: The Expression Problem
      16. 2.16 Related Work
      17. 2.17 Summary
    12. Chapter 3. Libraries
      1. 3.1 The Top Level
      2. 3.2 Scripts
      3. 3.3 Privacy
      4. 3.4 Imports
      5. 3.5 Breaking Libraries into Parts
      6. 3.6 Exports
      7. 3.7 Diamond Imports
      8. 3.8 Deferred Loading
      9. 3.9 Related Work
      10. 3.10 Summary
    13. Chapter 4. Functions
      1. 4.1 Parameters
        1. 4.1.1 Positional Parameters
        2. 4.1.2 Named Parameters
      2. 4.2 Function Bodies
      3. 4.3 Function Declarations
      4. 4.4 Closures
      5. 4.5 Invoking Methods and Functions
        1. 4.5.1 Cascades
        2. 4.5.2 Assignment
        3. 4.5.3 Using Operators
      6. 4.6 The Function Class
        1. 4.6.1 Emulating Functions
      7. 4.7 Functions as Objects
      8. 4.8 Generator Functions
        1. 4.8.1 Iterators and Iterables
        2. 4.8.2 Synchronous Generators
      9. 4.9 Related Work
      10. 4.10 Summary
    14. Chapter 5. Types
      1. 5.1 Optional Typing
      2. 5.2 A Tour of Types
      3. 5.3 Interface Types
      4. 5.4 Types in Action: The Expression Problem, Typed
      5. 5.5 Generics
        1. 5.5.1 The Expression Problem with Generics
      6. 5.6 Function Types
        1. 5.6.1 Optional Positional Parameters
        2. 5.6.2 Named Parameters
        3. 5.6.3 Call() Revisited
      7. 5.7 Type Reification
        1. 5.7.1 Type Tests
        2. 5.7.2 Type Casts
        3. 5.7.3 Checked Mode
        4. 5.7.4 Reified Generics
        5. 5.7.5 Reification and Optional Typing
        6. 5.7.6 Types and Proxies
      8. 5.8 Malformed Types
      9. 5.9 Unsoundness
      10. 5.10 Related Work
      11. 5.11 Summary
    15. Chapter 6. Expressions and Statements
      1. 6.1 Expressions
        1. 6.1.1 Literals
        2. 6.1.2 Identifiers
        3. 6.1.3 this
        4. 6.1.4 Constants
        5. 6.1.5 Creating Objects
        6. 6.1.6 Assignment
        7. 6.1.7 Extracting Properties
        8. 6.1.8 Method Access
        9. 6.1.9 Using Operators
        10. 6.1.10 Throw
        11. 6.1.11 Conditionals
      2. 6.2 Statements
        1. 6.2.1 Blocks
        2. 6.2.2 If
        3. 6.2.3 Loops
        4. 6.2.4 Try-Catch
        5. 6.2.5 Rethrow
        6. 6.2.6 Switch
        7. 6.2.7 Assert
        8. 6.2.8 Return
        9. 6.2.9 Yield and Yield-Each
        10. 6.2.10 Labels
        11. 6.2.11 Break and Continue
      3. 6.3 Summary
    16. Chapter 7. Reflection
      1. 7.1 Introspection
        1. 7.1.1 Implications for Speed and Size
        2. 7.1.2 Example: Proxies
        3. 7.1.3 Example: Serialization
        4. 7.1.4 Example: Parser Combinators
      2. 7.2 Why Mirrors
      3. 7.3 Metadata
      4. 7.4 Reflection via Code Generation
      5. 7.5 Beyond Introspection
      6. 7.6 Related Work
      7. 7.7 Summary
    17. Chapter 8. Asynchrony and Isolates
      1. 8.1 Asynchrony
      2. 8.2 Futures
        1. 8.2.1 Consuming Futures
        2. 8.2.2 Producing Futures
        3. 8.2.3 Scheduling
      3. 8.3 Streams
      4. 8.4 Isolates
        1. 8.4.1 Ports
        2. 8.4.2 Spawning
        3. 8.4.3 Security
      5. 8.5 Example: Client-Server Communication
        1. 8.5.1 Promise: A Brighter Future
        2. 8.5.2 Isolates as Distributed Objects
      6. 8.6 Asynchronous Functions
        1. 8.6.1 Await
        2. 8.6.2 Asynchronous Generators
        3. 8.6.3 Await-For loops
      7. 8.7 Related Work
      8. 8.8 Summary
    18. Chapter 9. Conclusion
      1. 9.1 Optional Typing
      2. 9.2 Object Orientation
      3. 9.3 Reflection
      4. 9.4 Tooling
      5. 9.5 Summary
    19. Bibliography
    20. Index
    21. Code Snippets