Posts

A More Stable Dart M1

Image
Happy Birthday Dart ! Today the Dart project announced the availability of Dart M1 , our first release since the initial technology preview launch almost a year ago. Hurray! To me, Dart M1 is a signal to developers that the project is stabilizing, and we encourage you to start building libraries and projects. The project isn't yet at 1.0, but this new M1 release contains many more platform features and language updates based on feedback we've received from the community. Now is a very good time to try Dart. More stable language The M1 launch signals that the Dart team is more comfortable with the language and is more confident that the days of fast-paced breaking changes are over. Based on feedback from users and the community, the Dart language evolved from its initial release. As Gilad Bracha, the Dart language spec lead, says, "My favorite part was deleting parts out of the spec." In other words, we added features but we also removed features. You can...

9 Dart Myths Debunked

Image
I survived  Addy Osmani's interview and lived to tell the tale. Watch the video below to see Dart myths debunked. Myth 1: Dart is out to replace JavaScript FALSE! Dart provides an option for non-endemic developers to help them be more productive building high-performance apps for the modern web. There are many skilled and productive JavaScript developers, but there are also many many developers familiar with Java, C#, C++, ActionScript, and more. Those developers have certain expectations around their tools and language, and we aim to meet and exceed those expectations. We're building in classes, interfaces, optional static types, lexical scope, optional parameters, generics, and more into the languages. We're building an editor capable of refactoring, quick fixes, static analysis, debugging, and more. Myth 2: It's either Dart OR JavaScript FALSE! Both JavaScript and Dart are technologies that Google believes in and invests in. Google participates i...

final variables in Dart

(Shameless stolen from my own Stack Overflow question and answer .) Dart has a concept of  final . Most dynamic languages don't have this concept. What is final and what do I use it for? final  variables can contain any value, but once assigned, a final variable can't be reassigned to any other value. For example: main() { final msg = 'hello'; msg = 'not allowed'; // **ERROR**, program won't compile } final  can also be used for instance variables in an object. A final field of a class must be set before the constructor body is run. A final field will  not  have an implicit setter created for it, because you can't set a new value on a final variable. class Point { final num x, y; Point(this.x, this.y); } main() { var p = new Point(1, 1); print(p.x); // 1 p.x = 2; // WARNING, no such method } It's important to realize that  final  affects the variable, but not the object pointed to by the variable. That is,  fina...

15 cool features of Dart

I wrote an answer on programmers.stackoverflow.com for the question " What are some useful features of the Dart programming language? " The answer, or 13 answers, was too epic to be contained. It is copied here for your reading enjoyment. (Like the answer? Please vote it up. Thanks!) 1)  Optional static types.  When I'm prototyping or simply writing small scripts, I don't use a ton of static types. I just don't need 'em, and I don't want to get bogged down with the ceremony. However, some of those scripts evolve into bigger programs. As the scripts scale, I tend to want classes and static type annotations. 2)  Innocent until proven guilty.  Dart tries hard to minimize the situations that result in a compile-time error. Many conditions in Dart are warnings, which don't stop your program from running. Why? In keeping with web development fashion, it's imperative to allow developers to try a bit of code, hit reload, and see what happens. The...

What Dart Wants

Image
In which a long-time JavaScript community member learns what Dart wants, and is pleasantly surprised. (Note, I'm speaking from my personal perspective in this post.) A reasonable question I received a nice email from Addy Osmani , my friend and colleague in Chrome Developer Relations. Addy is active with the JavaScript community, maintains TodoMVC archive , authors  web development tutorials , and more. It's fair to say that Addy is plugged into modern web development. Beastie Boys, So What Cha Want? (C) 2009 Capitol Records, LLC As a current web developer, Addy was curious about Dart's motivations and philosophy. Is Dart out to replace JavaScript? Who is checking out Dart? What is Dart doing? What does it want ? Luckily, Addy came to the right place. Here's what I wrote back. Choice is good We believe developer choice is good, and options are good. We believe Dart, which can provide a compelling option for modern web app development, ultimately brings ...

Running Dart in the Cloud with Heroku

Image
[EDIT: Updated on 2014-10-11] Dart , the new programming language for modern web apps, certainly compiles to JavaScript. Did you know that Dart also runs on the server as well? Thanks to Heroku's support for third-party runtimes, you can now run your server-side Dart app on Heroku 's cloud. Read on to learn how. (Disclaimer: Even though Heroku can host arbitrary runtimes, they don't officially support the Dart runtime.) Dart for modern web apps Dart is a class based, single inheritance, object-oriented, optionally typed language that is built to help developers of many backgrounds build awesome modern web apps. Most importantly, Dart compiles to JavaScript so that your Dart apps can run all over the web. Dart is familiar to JavaScript, Java, C, C++, and C# developers. There's even bits of Smalltalk in there. While it has a syntax that is instantly recognizable, it also has cool new features like optional static types and isolates . Check out the Dart langua...

Simple Dart + WebSocket demo

[EDIT: Updated on 2013-03-05] I just posted a simple demo of Dart with WebSockets . Not only does it show how to connect to a WebSocket server and send messages, it also shows off a few neat features of the Dart language . (The code follows below, or check out the full  open source project .) Look mom, no classes! Dart is a class-based object oriented language, but that doesn't mean you are required to wrap everything in a class. No sir, this is Dart, not Java. In Dart, you can use top level functions and top level variables. Libraries for modularity Dart organizes code into libraries for modularity. For example, this code uses the dart:html library for the WebSocket code. Concerned about bloat here? Don't be! Thanks to tree-shaking, the code that you don't use is eliminated during a (optional) compile step. The Dart to JavaScript compiler uses tree shaking to help generate minimal JavaScript code (still more work to do here). An upcoming Dart to Dart script wi...