Book Image

DART Essentials

Book Image

DART Essentials

Overview of this book

Table of Contents (16 chapters)
Dart Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Since the first public release of Dart in 2011, the language evolved a lot. Its first stable release in November 2013 marked the point when it was the time to start taking it seriously in the production environment. Dart 1.9+ might, at first sight, look like what JavaScript could be if it was designed for today's Web. It combines the best of many other languages while targeting both browser and server-side development.

Dart isn't the answer to every problem on the Web. There are situations where it seems like it's overly complicated to use Dart or it just isn't good at what you need, and you might be right. There are circumstances where it's better to use JavaScript.

This book tries to be objective. We won't try to convince you that from now on, you should use only Dart, and we'll talk about situations where Dart isn't the ideal solution. At the same time, we'll show you where Dart is great, how you can write well-structured code for both the browser and the server, and how easy it is to write understandable asynchronous apps with Dart 1.9.

Even though this book can't go into great detail about each topic, after reading this book, you should see for yourself that Dart makes sense and you should at least give it a try. It's not just the language but also the IDE, comfortable debugger, dependency management, runtime profiler, and more.

What this book covers

Chapter 1, Getting Started with Dart, jumpstarts Dart development right away while explaining the syntax and core features of Dart.

Chapter 2, Practical Dart, focuses on the most common tasks of client-side development, such as DOM manipulation, asynchronous programming, Ajax calls, and using existing JavaScript code in Dart and vice versa.

Chapter 3, The Power of HTML5 with Dart, specifically focuses on using HTML5 features in Dart while mentioning some noteworthy third-party libraries written for Dart.

Chapter 4, Developing a Mobile App with Dart, builds on the previous chapter with a quick explanation of CSS3 transformations and HTML5 features specific for mobile devices.

Chapter 5, Web Components and polymer.dart, goes step by step, showing each part of Web Components standard and how useful they are, even when used separately. Then, it looks at polymer.dart, which combines all parts of Web Components into a single framework.

Chapter 6, AngularDart, is a sneak peak of a superheroic framework for Dart made by Google with the same philosophy in mind as AngularJS.

Chapter 7, Server-side Applications with Dart, shows that apart from the browser environment, there's also a standalone Dart VM, which can run on a server. We'll take a very practical look at writing server-side scripts, including server configuration for Apache and nginx web servers.

Chapter 8, Testing and Profiling the Dart Code, states that just as with any other language, unit testing is a vital part of the development process. Dart also comes with a built-in tool called Observer to examine Dart VM's internals in runtime.

Chapter 9, Writing Native Extensions for the Standalone Dart VM, shows the full potential of Dart, by writing native extensions for the standalone Dart VM in C/C++ and then using them from Dart.

What you need for this book

The only software you need is the Dart SDK. Right now, it's available for all recent releases of Windows, OS X, and Ubuntu Linux.

In Chapter 9, Writing Native Extensions for the Standalone Dart VM, we'll also need a C/C++ compiler, ideally GCC, which is free. This is actually optional; you don't need it if you don't want to try the examples for yourself.

Who this book is for

This book is intended for developers with prior knowledge of programming in any OOP language, with a reasonable background in web development and decent experience with JavaScript.

We're not going to go through basic programming constructs, such as conditionals, loops, boolean expressions, and similar things, which are common to all languages.

Also, we're not going to explain concepts of OOP.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The Reddit API allows us to set a custom callback with the jsonp parameter."

A block of code is set as follows:

import 'dart:html';
main() {
  print("Hello, world!");
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<input type="time" ng-model="newTask['when']">
<input type="text" ng-model="newTask['title']">
<button type="button"
    ng-click="addTask(newTask['when'], newTask['title'])">
Add</button>

Any command-line input or output is written as follows:

# dart bin/server.dart -p 8889

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the Emulation tab, click on Sensors and you should see three input fields, each for one axis."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/9607OS_GraphicsBundle.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.