Tuesday, December 11, 2012

New Dart Web UI Codelab

Originally posted on Dart News & Updates:

If you've been waiting for the right time to learn how to use Web Components in Dart, now's your chance! Continuing where we left off with the Google IO 2012 Dart Codelab, I've created a Dart Web UI Codelab which focuses on Web Components and the new Web UI library.

In this codelab, I cover:

  • How to set up pub
  • How to use Web Components
  • How to use dynamic templates and two-way data binding (inspired by Model-driven Views)
  • How to build an application with multiple Web Components
  • Where to get more information about Web Components and the Dart Web UI package
  • What to do if you get stuck while trying to build an app using the Dart Web UI package

We've already created videos, blog posts, and articles about how to use Web Components in Dart, but this codelab is pretty exciting in that it walks you through building a complete, albeit small, application using Web Components and the Dart Web UI library. So give it a try and tell us what you think!

We invite you to join the Dart Web UI mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

Monday, December 10, 2012

An Approach to Illiterate Programming: doc-code-merge

Reposted from Dart News & Updates:

It's very common to embed code examples in technical documentation. However, doing so is kind of painful. First of all, the environment you use to edit the documentation may not be the same as the environment you use to write code. For instance, I generally use Dart Editor to write Dart code, but I use Sublime Text 2 to edit documentation written in HTML or Markdown. Secondly, it's difficult to run unit tests or use dart_analyzer if the code is trapped in documentation. This is a big problem for us on the Dart project because we move pretty quickly, and we want to make sure our documentation is always 100% correct. I've created a tool called doc-code-merge to solve this problem.

doc-code-merge is the opposite of what Donald Knuth labelled Literate Programming. doc-code-merge lets you write your documentation and your code examples completely separately. When you run doc_code_merge.dart, it makes a copy of your documentation with all the examples merged in. The Pragmatic Programmers mentioned using a similar tool when writing The Pragmatic Programmer: From Journeyman to Master, so the idea has probably been around for a while.

Using doc-code-merge is easy. Start by writing some documentation such as:

Then, write some code such as:

Now, run doc_code_merge.dart:

This results in:

Easy peasy! doc-code-merge automatically handles things like indenting code blocks when generating Markdown and HTML escaping code when generating HTML.

Although doc-code-merge is written in Dart, it'll work with almost any programming language and with almost any type of documentation as long as the documentation is written in text such as HTML or Markdown. We're hoping to make use of it for the Dart web site, dartlang.org, and for our book on Dart, Dart: Up and Running.

If you're interested in using doc-code-merge, check out the README. As always, we invite you to join the Dart mailing list and ask questions on Stack Overflow.

Friday, December 07, 2012

Dartisans Ep. 16: Dart and Web Components Reloaded

In this episode of Dartisans, Dimitri Glazkov (one of the godfathers of Web Components) gives a presentation on Web Components. Also, John Messerly and Siggi Cherem (who helped build the dart-lang/dart-web-components library) give a presentation on using Web Components in Dart. A lot of things have changed since our last episode focused on Web Components, and this was a must-see episode if you're interested in Web Components and/or Dart!