Tuesday, January 22, 2013

Dart: My Experience Porting to Library v2

Updated: January 25, 2013: I ported the rest of my code. Hence, I updated the list below.

I ported all of my code to Dart lib v2. Here's what I had to do to get all of my projects to work:

  • Timer is now in 'dart:async', not 'dart:isolate'.
  • Element.elements is now Element.children.
  • LocalWindow is now Window.
  • window.webkitRequestFileSystem is now window.requestFileSystem.
  • Completer.completeException is now Completer.completeError.
  • Future.handleException is now Future.catchError. Furthermore, it no longer receives a "bare" exception object. It receives an AsyncError object. Use AsyncError.error to get the original exception object.
  • You have to use .then() and .catchError() in a single chain such as produceFuture().then((value) => null).catchError((e) => null). If you do this as two separate calls on the same future, the wrong thing will happen.
  • innerHTML is now innerHtml.
  • window.webkitNotifications is now window.notifications.
  • Map.keys and Map.values return iterators, not lists. This might break your code even if there are no static warnings. If you need a real list, call .toList() on the iterator.
  • BiquadFilterNode.type now takes a string such as "lowpass" instead of an int such as 0 or LOWPASS. I created a bug (http://code.google.com/p/dart/issues/detail?id=8119) to change that to a string.
  • AudioBufferSourceNode, BiquadFilterNode, etc. have connect and disconnect methods that have input and output parameters. It used to be acceptable to pass null for those parameters. To get the same behavior now, you must pass 0. You will not get a static warning if you don't update your code. It'll fail at runtime.
  • FileReader.readAsDataURL is now FileReader.readAsDataUrl.
  • StringBuffer.add no longer returns the StringBuffer. Use method cascades instead.
  • new Path.fromNative is now just new Path.
  • Iterable.some is now Iterable.any.
  • Iterable.map is now Iterable.mappedBy.
  • Future.chain is now Future.then.
  • Change "import 'dart:json'" to "import 'dart:json' as JSON" since there is no
  • JSON class anymore.

There are lots of other things that have changed, but those are the things that I got hit with.

Monday, January 07, 2013

Esto es Dart

Cross-posted from Dart News & Updates.

This is a blog post for Spanish-speaking developers who may be interested in learning Dart. Please pass it along to any Spanish-speaking developers you know!

En su libro El programador pragmático, David Thomas y Andrew Hunt recomiendan "aprender al menos un lenguage nueva cada año." Bueno, es un nuevo año, y creo que ahora es un buen momento para aprender un nuevo lenguage. De hecho, si usted todavía no ha aprendido Dart, no hay mejor momento!

El año pasado, empecé a estudiar español para poder compartir con todos los hispanohablantes del mundo mi introducción a Dart traducido al español. Después de pasar dos días delante de un micrófono tratando de no sonar como si tuviera canicas en mi boca, les presento a Esto es Dart! Espero que les guste.

In English:

In their book The Pragmatic Programmer, David Thomas and Andrew Hunt recommend that you "learn at least one new language every year." Well, it's a new year, and now's a great time to learn a new language. In fact, if you haven't learned Dart yet, there's no better time!

Last year, I started studying Spanish so that I could reach out to all the Spanish speakers of the world with my introduction to Dart translated to Spanish. After spending two days in front of a microphone trying not to sound like I have marbles in my mouth, I present to you Esto es Dart! I hope you enjoy it.

Thursday, January 03, 2013

More Dart HTML5 Goodness

Cross-posted from Dart News & Updates.

dart-html5-samples is a collection of HTML5 samples written in Dart. Most of them were ported from HTML5 Rocks. I first blogged about dart-html5-samples about three months ago. Since then, a ton of cool, new HTML5 samples have been ported to Dart, and we've updated all the samples for M2!

Here is the current list of samples:

There are a couple samples that I want to point out because they're so interesting. Adam Singer ported Eric Bidelman's terminal sample. Try clicking near the cursor and typing help. Here's the source.

John McCutchan, who clearly has a background in video gaming, ported his Pointer Lock And First Person Shooter Controls sample to Dart. Here's the source.

Special thanks go to Adam Singer, Shailen Tuli, John McCutchan, and Jason Brooks for their help on the project. If you're interested in contributing new HTML5 samples, check out the README for how to get started! As always, if you’d like to chat more about this, feel free to send us email on the mailing list or ask questions on Stack Overflow.