Introduction

Why Dart?

Looking back more than two years to the first edition of this book (really? that long?), I realize that my answer to “why Dart?” has changed. A lot.

I am very much a language, library, and protocol hipster. I love learning new stuff. The fun of learning is very much its own reward, but that is not the main reason that I learn. It is always nice to add another tool to the developer’s proverbial toolbox, but I have come to realize even that is not the main driving force to learning.

The main reason that I learn new things like Dart is that I find it to be a most effective way to understand problems from the perspective of others. The folks who write libraries and languages are invariably smarter and/or know the subject matter better than I do, so learning the solutions is a crash course on understanding the problems that currently exist. Even if I cannot use a shiny new tool right away, the challenges faced and overcome by tool authors stick with me.

So, when I first approached Dart, it was very much in that spirit. And wow, did it ever work! I learned a ton from the language and from interacting with people on the mailing list and in blogs. It profoundly affected my way of thinking—not only about languages like JavaScript (which I still love)—but about programming for the Web in general.

That would have been my answer from two years ago. I learn Dart—and I think others should learn it too—because it profoundly affects the way that one thinks about programming for the Web.

But since then…

I have really come to appreciate the intrinsic beauty and value of Dart. More and more, it is my “go to” tool to fulfill important needs. And I love using it.

Dart is not a JavaScript replacement. Let me repeat that: Dart is not meant to replace JavaScript. It is much more. It took me a long while to understand this, but Dart is not a competitor with JavaScript-the-language. It is a competitor with the platform that supports developing JavaScript. And Dart is so far ahead of JavaScript-the-platform that I would consider it a programming mortal sin to use JavaScript when Dart is an option.

I do not hate JavaScript-the-language. Far from it, in fact. Since the first edition of this book, I wrote a kids programming book that uses JavaScript to introduce programming to kids. I am not even a closet JavaScript hater who prefers to use “prettier” compile-to-JavaScript languages like CoffeeScript or TypeScript. Even though each of those compile-to-JavaScript languages offers some benefits over pure JavaScript, I like JavaScript enough to code it by itself.

What I do not care for in JavaScript-land is…everything else. Manipulating the DOM is a pain, so we must have a library for that. XMLHttpRequest is ugly, so we need a library for that. Testing is not built in, so a library is needed for that (and test runners and test assertions too!). And a library to manage large codebases. And, of course, we need a library to manage all the libraries. And (some of us) need a library to make JavaScript prettier. And don’t even get me started on cross-browser testing, which never does seem to go as planned…

I dislike JavaScript-the-platform because I spend so much time building and maintaining it that I do not focus on what is important: building insanely great applications. With Dart, a consistently beautiful DOM library is built in. HttpRequest, which comes standard with Dart, makes Ajax a breeze. Libraries and packages are included from the outset. Testing is beautiful and easy.

Most importantly, Dart compiles to cross-browser JavaScript. Unlike every other compile-to-JavaScript language out there, Dart does not generate JavaScript and hope for the best. It targets a Dart-specific JavaScript compatibility layer that ensures that your crazy animations, visualizations, and effects work everywhere across the modern Web. (Note: The modern Web has a specific meaning for Dart. It is the latest two versions of each of the major browsers: Chrome, Firefox, Safari, Opera, and Internet Explorer. The main reason—some would argue the only reason—not to use Dart is when support for old versions of Internet Explorer—9 and lower—is a hard requirement.)

Oh, and did I mention that Dart is a pretty language? Well, it is and it lets you write beautiful, maintainable code.

So my answer to “Why Dart?” has changed. Dart is the ideal language and platform for development on the modern Web. It will still profoundly affect how you think. But today it is more. It is the best way to create and maintain insanely great applications on the modern Web.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.10.1