<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>davidflanagan.com</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.davidflanagan.com/atom.xml" />
    <id>tag:www.davidflanagan.com,2008-10-28://1</id>
    <updated>2012-02-02T00:24:58Z</updated>
    <subtitle>books for programmers</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>

<entry>
    <title>Webmaker Scrapbooks</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2012/02/webmaker-scrapb.html" />
    <id>tag:www.davidflanagan.com,2012://1.225</id>

    <published>2012-02-01T23:51:28Z</published>
    <updated>2012-02-02T00:24:58Z</updated>

    <summary>My colleagues at the Mozilla Foundation want to &quot;create a web literate planet&quot; and &quot;educate a generation of web makers&quot;. Some are working to figure out just what those phrases mean. While others are just going out and teaching stuff....</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="web literacy" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>My colleagues at the Mozilla Foundation want to "create a web literate planet" and "educate a generation of web makers".  Some are <a href="http://rwxweb.wordpress.com/">working to figure out just what those phrases mean</a>.  While others are just going out and <a href="http://hackasaurus.org">teaching</a> <a href="http://lovebomb.me">stuff</a>.  </p>

<p>I signed up to write about web literacy, but keep finding myself pulled back to teaching basic JavaScript programming as a webmaker skill and as a critical thinking skill.  (And today's <a href="http://openmatt.wordpress.com/2012/01/30/teaching-the-fourth-r/">fireside chat</a> about "algorithmic thinking" has only fanned the flames of that desire.)</p>

<p>I've created a very simple JavaScript-based turtle graphics library (and even tried it out on some second graders) and have been pondering some other kinds of math and science explorations that can be facilitated with JavaScript, SVG, and other web technologies.  (Nothing published yet; I'll blog here when I've pushed a repo to github.)</p>

<p>So we're teaching webmakers by showing them how to remix websites, create online valentines, and (if I have my way) use turtles to draw pretty patterns.  Each of these activities has a way (we'll, mine doesn't yet) to publish the results to a public web page so they can be shared with friends, shown to parents, and so on.</p>

<p>I had a minor epiphany about this today, which is why I'm writing this now.  Here it is: we ought to allow junior webmakers to collect everything they publish, as well as the <a href="https://wiki.mozilla.org/Badges">badges</a> they earn, into an online "webmaker scrapbook".  It would be like a blog or github for kids, but more colorful and fun.</p>

<p>Having a scrapbook helps with continuity: a young person might start something at one hackasaurus event, and then come back to another and continue it or create a new version of it.  Keeping everything together also allows participants to go back and see how much they've learned and how far their skills have grown since they started.   And I think the scrapbook metaphor sets a good tone for the collection of works: these are things that a young webmaker should be proud of and want to preserve and remember.</p>

<p>Finally, for kids who like scrapbooking, this idea gives them another compelling reason to learn HTML and CSS skills: so they can decorate their scrapbook in fun ways.</p>

<p>I'm not sure that I'm making any sense here.  Your feedback is welcome in the comments!<br />
 </p>]]>
        
    </content>
</entry>

<entry>
    <title>Mozilla and Web Literacy</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2012/01/mozilla-and-web.html" />
    <id>tag:www.davidflanagan.com,2012://1.224</id>

    <published>2012-01-26T00:24:38Z</published>
    <updated>2012-01-26T00:35:04Z</updated>

    <summary> Mark Surman, the head of the Mozilla Foundation, has proposed that as part of Mozilla&apos;s mission (&quot;to promote openness, innovation and opportunity on the web&quot;) we should work to &quot;create a web literate planet&quot;. His vision inspires me: if...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="web" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>
Mark Surman, the head of the Mozilla Foundation, <a
href="http://commonspace.wordpress.com/mozilla-learning-proposa/"> has
proposed</a> that as part of <a
href="http://www.mozilla.org/about/mission.html"> Mozilla's
mission</a> ("to promote openness, innovation and opportunity on the
web") we should work to "create a web literate planet".  His vision
inspires me: if the web is going to continue to be a revolutionary
force in human affairs, we need a critical mass of citizens who
understand the web deeply, who actively participate and build the web,
and who can not be turned into mere consumers.  So I've taken a break
from my work on <a
href="https://github.com/andreasgal/dom.js">dom.js</a> to work on
education and web literacy.

<p>
Michelle Levesque works for the Mozilla Foundation and has been 
<a href="http://rwxweb.wordpress.com/">thinking a lot about</a> web
literacy under the name "webmaker skills".  That is, she's working on
listing the skills that Mozilla feels are most important in order for
someone to be "web literate", where literacy means not just "reading"
the web, but writing, or "making" it, too.

<p>
Mozilla is teaching webmaker skills through a number of really
interesting projects and experiments including:

<ul>

<li>HTML and CSS editing with <a href="http://hackasaurus.org/">Hackasaurus</a> and
<a href="http://lovebomb.me/">Lovebomb.me</a>.

<li>Web movies with <a href="http://mozillapopcorn.org/">Popcorn.js and PopcornMaker</a>.

<li>Putting web makers into newsrooms through the <a
href="http://openmatt.wordpress.com/2011/11/17/fusing-journalism-tool-building-and-code/">Knight-Mozilla
News Technology Partnership</a>.
</ul>

<p>These projects tend to approach web literacy stealthily, and teach or promote
it as a side effect of making cool stuff online.  Given my background
as a writer, however, I'll probably take a more direct approach and
just write about web maker skills. (I don't expect that any of the
teens learning HTML with Hackasaurus will ever read what I write, but
perhaps the adults teaching them will...)

<p>I can't write about web literacy the way I write about JavaScript,
of course. Many webmaker skills are probably ones that are best learned by doing rather than by reading.  And no one really knows exactly what we mean by "web literacy" anyway. Still,
there are plenty of web literacy topics that <i>can</i> be addressed in
prose, from
"what is a web browser?" and "what is the difference between a URL and
search query?" to "how do I write HTML and CSS" and "what is DNS?"

Other crucial web literacy topics (harder ones to write about)
include:

<ul>
<li>Identity, anonymity and privacy on the web.

<li>Copyright, fair-use and other IP laws and the web.

<li>The difference between the open web and walled gardens erected
within the web.

<li>How to detect scams and misinformation on the web.

<li>The seedy neighborhoods of the web: typo squatters, aggressive
SEO, comment spam, etc.

<li>The dark side of the web: phishing, malware, etc.
</ul>

<p>        
(Please feel free to suggest other web literacy topics in the
comments.  Or if you know of particularly good writeups on these or
other topics, let me know.)

<p>
I'm actually debating whether to use the term "web literacy" at all,
or to just stick to "web skills".  The word "literacy" carries a lot of
academic baggage, and that some of that baggage, like the "digital
native" vs. "digital immigrant" distinction, is bogus. The literacy
metaphor is really quite appealing, but it might actually be more
trouble than it is worth.

<p>
You may notice that one of the web skills not listed above is
JavaScript programming. I've thought a lot about the question of how
to teach kids to program with JavaScript, and it is an area that I'd
<i>love</i> to work on.  But its a hard problem, and <a
href="http://www.youtube.com/watch?v=nvaaude_1hk">others</a> are <a
href="http://www.codecademy.com/">tackling</a> it, so it may not make
sense for Mozilla to jump in.  Still, its very tempting to put together some JavaScript explorations for kids.
]]>
        
    </content>
</entry>

<entry>
    <title>TeamJS Wrap Up</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2012/01/teamjs-wrap-up.html" />
    <id>tag:www.davidflanagan.com,2012://1.223</id>

    <published>2012-01-13T05:01:19Z</published>
    <updated>2012-01-23T17:07:38Z</updated>

    <summary>The Mozilla Firefox Challenge celebrity fundraiser contest has ended, and the JavaScript community&apos;s entry, TeamJS did amazingly well: We raised $25,000 for Feeding America, a US charity that collects surplus food on a massive scale and distributes it to a...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="teamjs" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>The <a href="http://crowdrise.com/firefoxchallenge">Mozilla Firefox Challenge</a> celebrity fundraiser contest has ended, and the JavaScript community's entry, TeamJS did amazingly well:

<ul>
<li>We raised $25,000 for <a href="http://feedingamerica.org">Feeding America</a>, a US charity that collects surplus food on a massive scale and distributes it to a national network of food banks that in turn distribute it to hungry people.

<li>The $25,000 we raised will enable Feeding America to obtain $400,000 worth of food, which works out to 200,000 meals for people who might otherwise not eat.

<li>After spending a week or two <a href="http://twitpic.com/7u9fbu">in first place</a> we ended up 8th in the contest, behind 5 of the original celebrity entrants, and ahead of 7 of the celebrities.  We raised more money than Barbra Streisand, Sean Penn, Will Ferrell, and four others, all of whom had a $5,000 head start courtesy of <a href="http://mozilla.org">Mozilla</a>.

<li>I'd like to believe that we also strengthened our JavaScript (and web developer) community, too!
</ul>

<p>$25,000 is a lot of money and it will do good for a lot of people. My heartfelt thanks to <i>everyone</i> who made this happen!  You know who you are, and if you don't you can find the names of the non-anonymous donors at the <a href="http://crowdrise.com/TeamJS">TeamJS page</a>.  Look for the scrolling list, or use  view-source to see the complete list more quickly.  (Incidentally, even though the contest is over, you can still make donations to Feeding America through that page, so if <i>your</i> name isn't on that list, you can still make it appear.)

<p>There are a few people and organizations that I'd like to single out for special thanks:

<p>I started TeamJS on a lark (okay, because I was bored with my programming project) and I really can't take much credit for its success.  I am proud of myself, however, for getting <b>Chris Williams</b> involved.  As I said to him in my first email, "I think this might be your kind of crazy".  It turns out I was right.  Chris kicked things of with a big crazy donation of $5,000 from <a href="http://2012.jsconf.us/">JSConf</a> and then whipped the JavaScript community into a giving frenzy by offering a conference discount to anyone who gave $100 to TeamJS.  Without Chris's early generosity I don't think TeamJS would have ever reached the $5000 mark. But it isn't just Chris's financial generosity: he's a natural leader and community builder and has the chutzpah to tweet outlandish statements like "the most important thing you'll do today is donate to TeamJS".  It just kind of makes sense when Chris says it.  Oh, and also, the black and yellow JS logo that TeamJS used was Chris's gift to the JavaScript community.  Thank you, Chris, for all that you do!

<p>I also want to thank <b>the team at <a href="http://jupiterjs.com">Jupiter JavaScript Consulting</a></b> for a $1000 group gift.  If I recall correctly, it came near the end of that first crazy day of donations after Chris kicked things off, and propelled us past $10,000 and into the big time.  

<p>As the contest drew to a close, TeamJS was languishing at around $14,000  All our momemtum was gone, and we were slipping down the leaderboard into 12th place.  Out of the blue <b>Cody Lindley</b> matched Chris William's awesomeness and donated $5,000.  (Cody is the author of <i><a href="http://www.javascriptenlightenment.com/">JavaScript Enlightenment</a></i>, which, by all reports, is an <i>excellent</i> book.)  Cody inspired me to increase my own donation, and his big give really brought the excitement back. Thank you Cody! Your  $5,000 donation put us within reach of our $25k goal and brought in almost $5,000 in smaller donations: on the last day we had about 60 new donations that brought us up to $23,780 just before the contest ended at midnight.

<p>But the story, and the thank yous, don't end there.  At 7 minutes to midnight, <b>Peter deHaan</b> donated $1,220 to bring us to <i>exactly</i> $25,000.  How perfect for a team of geeks: we met our goal to 5 significant digits and finished exactly on schedule Thank you Peter, for closing out the contest in style: it was a perfect ending!

<p>What a ride!  Thank you everyone for being so awesome!

]]>
        
    </content>
</entry>

<entry>
    <title>Who Stores all the Lovebombs of the Writable Web?</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2012/01/who-stores-all.html" />
    <id>tag:www.davidflanagan.com,2012://1.222</id>

    <published>2012-01-05T23:56:54Z</published>
    <updated>2012-01-23T17:09:17Z</updated>

    <summary> I&apos;ve been thinking a lot recently about Mozilla&apos;s mission to promote the open web. Part of that mission, a part I&apos;d like to be involved in, has been described as &quot;educating the next generation of web makers&quot; and as...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="web" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>
I've been thinking a lot recently about Mozilla's <a
href="http://www.mozilla.org/about/mission.html">mission</a> to
promote the open web.  Part of that mission, a part I'd like to be
involved in, has been described as "educating the next generation of
web makers" and as <a
href="http://commonspace.wordpress.com/mozilla-learning-proposa/">"creating
a web-literate planet"</a>.  And an important part of web literacy
(and web making, of course) is the realization that the internet is
not just for consumption of information, but that it is
<em>writable</em>.
<p>
Do you remember what the web was like before blogs and wikis? The web
was only writable if you were a "webmaster". (Does anyone even use
that term anymore?) This meant, at a minimum that you could edit HTML
and understood how to use ftp.  (And a working knowledge of
&lt;frameset&gt; and &lt;marquee&gt; was nice, too. :-)
<p>
Blogs changed this by making it radically simpler to publish content
to the web.  You didn't have to be a webmaster anymore, you could just
be a blogger. It made a huge difference at the time. In this age of
Twitter, though, blogging feels like a chore. My blogging software
runs sluggishly on my webhost, there's always comment spam to deal
with, RSS feeds are always a mystery, and my templates are 
out-of-date (I've been meaning to take the ads off the site, but
haven't made the time.)
<p>
I don't use Facebook, but I gather that publishing content in Facebook
is much easier than blogging.  But (and this is a really important
point to understand) Facebook isn't the open web, so it doesn't count.
<p>
It seems to me if the web is going to be truely writable, we need a
paradigm shift that makes it even easier to create and publish content
than blogging software does.
<p>
<a href="http://www.toolness.com/wp/">Atul Varma</a> and <a
href="http://jessicaklein.blogspot.com/">Jess Klein</a> have taken a
step in this direction with <a
href="http://lovebomb.me">lovebomb.me</a> and the related <a
href="http://toolness.github.com/webpage-maker-prototype/">Webpage
Maker</a> and <a
href="http://webpad.hackasaurus.org/">webpad.hackasaurus.org</a>.
Their goal is to teach kids how to write HTML and CSS.  But they don't
want to send the kids off on a quest to register a domain, purchase a
hosting plan and learn how to use scp for uploading pages. If kids are
going to learn to create and edit web pages, they need a way to
publish their work and immediately show it to friends, parents and
teachers. So what each of these sites does is host the user's content
for them at a short random URL, in the same way that sites like <a
href="http://pastebin.com">pastebin.com</a> and <a
href="http://jsbin.com">jsbin</a> do.
<p>
This is a great solution for lovebomb.me, hackasaurus, and jsbin:
those sites have a relatively small community of users and are used
for relatively specific purposes.  But it doesn't scale to make the
whole web writable (maybe it could scale if Google hosted it, and the
"writable web" was just a collection of Google Docs documents :-). In
addition to the issue of not having unlimited storage space, there is
also the administrative and legal issues of how to deal with the
inevitable problems of spam, malware, pornography, and hate speech
that will come to infest anonymously writeable sites like these.
<p>
Many of us are already publishing our content all over the web, with
the help of commercial or ad-supported services:
<p>
<ul>
<li>blog posts at blogger.com, etc.
<li>photos at flickr.com, etc.
<li>source code at github.com, etc.
<li>music at mp3locker.com, etc.
<li>documents and spreadsheets at docs.google.com
</ul>
<p>
So that brings me, finally, to the point of this post: who stores the
writable web?  Publishing content to the web ought to be as easy as
<b>File -&gt; Save As</b>. But where does that content go? Do I have
to own a domain and pay for webhosting to be a web maker, or can I use
a service to handle the storage details for me? And can I publish all
my content in once place, or do I have to rely on different storage
services for different types of content?
<p>
I don't have any answers, or even any proposals, really.  Only
questions:
<ul>
<li>Can we decouple the way we refer to web content from the
details of where that content is hosted? 
<li>Do we need some higher-level
URI scheme that allows web makers to store all their content in a
single hierarchical namespace that is independent of domain names of
the services that actually store that content?
<li>Can identity service
providers (like <a href="http://browserid.org">BrowserId</a>) tackle
this problem by defining a namespace that refers to all the content
defined by or owned by each identity?
<li>Can storage service providers define a working "Save
As" feature for the writable web?
</ul>
]]>
        
    </content>
</entry>

<entry>
    <title>Subscription Music Services: Who Owns your Playlists?</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/12/subscription-mu.html" />
    <id>tag:www.davidflanagan.com,2011://1.221</id>

    <published>2011-12-27T18:20:48Z</published>
    <updated>2012-01-05T18:52:24Z</updated>

    <summary>I&apos;m a big fan of subscription music: I love the model of being able to listen to whatever you want whenever you want. Its all out there on the web and I don&apos;t have to be bothered with actually owning...</summary>
    <author>
        <name>David</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>I'm a big fan of subscription music: I love the model of being able to listen to whatever you want whenever you want. Its all out there on the web and I don't have to be bothered with actually owning any of it.  Compared to the cable TV or internet bill (or any other utility, really) $10/month seems like a small price to pay for unlimited music.</p>

<p>I'm an old-timer at this: I've been a Rhapsody subscriber for 5 years.  If you've used Rhapsody, you probably know that it sucks. Their Windows client is built around IE. They still after all these years don't have a Mac or Linux client.  Their servers often seem sluggish.  Given the nature of the buisness they're in, their legal team probably dwarfs the size of their developer team.  They haven't done anything innovative in years.  I'm ready to get out.</p>

<p>There have always been other music services, but until recently, they've been about purchasing music, or have been radio format where you can't choose exactly what you listen to.  But finally, Rhapsody has competition in the subscription business with services like MOG, Spotify and Rdio.  MOG now has an app for my Squeezebox players, so I've signed up for a 2 week trial and am liking what I see so far.  (Aside to Spotify: Facebook-only login?  Really? I hear good things about you, but I'm not going to create a Facebook account to try you out.)</p>

<p>The problem is that after 5 years on Rhapsody, my family has hundreds of albums in "My LIbrary" (Rhapsody's term for your set of favorites) and quite a few long custom playlists.  I don't want to start over from scratch to re-favorite those albums and re-create those playlists. Rhapsody owns my data and they've got me locked in.  (More accurately, perhaps, Rhapsody controls my data and that's a barrier to me leaving them for a better service.)</p>

<p>Frankly, I'm shocked that new services like MOG have entered this market without an "import playlists" feature.  Web browsers can import the bookmarks of other browsers.  One of the first things MOG should have done when I signed up is to ask me for my Rhapsody credentials so that it could copy everything over.  Seems like a no-brainer and a huge money-maker, so why hasn't anyone done this?  Maybe there is fine-print in the Terms of Service that prevent it? Maybe all of the services are afraid they'd lose more customers than they'd gain if this became the norm?</p>

<p>Really, though, having MOG import my Rhapsody favorites and playlists isn't the best model anyway: then MOG controls my data and I'll run into this problem all over again if I decide to switch to some other service.  The right model is that every music listener should own and control their own musical preferences.  I should be able to edit my playlists using 3rd-party applications (personally, I'd like to use emacs!) and be able to sync them with any subscription services I choose.  Logitech has an opportunity here to serve the owners of their Squeezebox players. Squeezebox owners (myself included) typically enter their subscription service credentials into the mysqeezebox.com site, so they are automatically in a perfect position to create a playlist transfer squeezebox app.</p>

<p>Really, though: this is probably a job for a trusted non-profit organization dedicated to protecting the open web: Mozilla!  I imagine it would be a great project for Mozilla Labs. (I work for Mozilla, but not in Labs. I'm not speaking for Mozilla or Mozilla Labs in this post, of course.)</p>

<p>Technically, this shouldn't actually be too hard.  Any subscription service with a Web interface (I think that is most or all of them) has an HTTP-based API for listing and editing playlists.  And any service that supports Squeezebox players has a stable API that they're willing to let other devices rely upon.  The Squeezebox code is open-source so it might even be possible to use some of that code. Listing a user's favorites and getting the contents of her playlists ought to be pretty easy. Adding favorites to a new service should also be relatively easy, I think.  Creating and populating new playlists on a new service is probably the hardest thing.  I don't think this is doable on a Squeezebox, so it may involve some reverse engineering of each service's web API.</p>

<p>The playlist migration and sync application I imagine would run in a web browser and would store music service credentials and playlists locally, with no server-side involvement. We'd have to write import and export modules for each music service and then also define modules for importing and exporting playlists to sharable open formats like plain-text, XML, and CSV.</p>

<p>I wonder if I can get something basic working before my 14-day free trial at MOG expires?<br />
If I write any code, I'll put it up on <a href="http://github.com/davidflanagan">github</a>.</p>

<p>I'd love your thoughts! Please share your comments below.<br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>If You Weren&apos;t Paying Attention on Friday</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/12/if-you-werent-p.html" />
    <id>tag:www.davidflanagan.com,2011://1.220</id>

    <published>2011-12-19T15:29:30Z</published>
    <updated>2011-12-27T18:19:17Z</updated>

    <summary> If you weren&apos;t paying attention to the #teamjs hashtag on Twitter on Friday, you missed out on a lot of excitement and a great JavaScript community moment. If you were part of the fun, then you probably know all...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="teamjs" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>
  If you weren't paying attention to the #teamjs hashtag on Twitter on
  Friday, you missed out on a lot of excitement and a great JavaScript
  community moment. If you were part of the fun, then you probably
  know all this already, and should
  see <a href="http://www.davidflanagan.com/2011/12/teamjs-update-a.html">TeamJS
  Update and What's Next</a> instead.

<p>
  TeamJS is a group of JavaScript programmers and other web developers
  who are <a href="http://crowdrise.com/TeamJS">raising money</a>
  for <a href="http://feedingamerica.org">Feeding America</a> as part
  of the <a href="http://crowdrise.com/firefoxchallenge">Mozilla
  Firefox Challenge</a>.

<p>
  The <a href="http://crowdrise.com/firefoxchallenge">Mozilla Firefox
  Challenge</a> is a celebrity fundraiser, sponsored by
  Mozilla. Mozilla got 12 celebrities involved, donated $5,000 to
  their favorite cause and asked the celebrities to compete to raise
  more money through <a href="http://crowdrise.com">CrowdRise</a> for
  that cause. Whichever charity raises the most money before January
  11th will win an additional $25,000 from Mozilla.

<p>
  But the competition isn't limited to the initial 12 celebrities:
  there are no celebrities behind TeamJS, and we didn't get any seed
  money from Mozilla. TeamJS started off as a lark to see whether the
  JavaScript and web developer community could donate some money and
  get the black-on-yellow JavaScript logo on the leaderboard among the
  celebrities faces.

<p>
  But then something amazing happened! On Friday morning Chris
  Williams, the big-hearted organizer of JSConf (JavaScript's premiere
  conference) donated $5000 on behalf
  of <a href="http://jsconf.us">JSConf</a>. That put us on an even playing
  field with the celebrities and, when combined with donations from
  Wednesday and Thursday, it catapulted us into the middle of the
  pack.

<p>
  That seed money opened the floodgates and the money began to pour
  in.  When I left the office Friday evening, TeamJS was in second
  place. When I got home, we were first. The evening ended with
  another big $1,000 donation
  from <a href="http://jupiterjs.com">Jupiter Consulting</a> that
  brought us close to $11,000 in total donations. We were no longer
  just in first: we had a $2,000 lead and had left the celebrities in
  our dust.  (As I write this Sunday night, we have raised $12,211 and
  second place is Sophia Bush with $9,990.)

<p>
  It was a really amazing day, but what it means is that this is no
  longer a lark: we could actually win this contest. Please join us
  and <a href="http://www.davidflanagan.com/2011/12/teamjs-update-a.html">let's
  make this an amazing week!</a>

<p>
  Read more about our charity, Feeding America and give whatever you
  can at <a href="http://crowdrise.com/TeamJS">the TeamJS page</a>.


]]>
        
    </content>
</entry>

<entry>
    <title>TeamJS Update and What&apos;s Next</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/12/teamjs-update-a.html" />
    <id>tag:www.davidflanagan.com,2011://1.219</id>

    <published>2011-12-19T14:58:44Z</published>
    <updated>2011-12-27T18:17:22Z</updated>

    <summary> Friday was a lot of fun! We went from nowhere to first place with $12,000 in donations for Feeding America. But we were so successful that we actually have a chance to win, which means that we can&apos;t just...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="teamjs" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>

  Friday was a lot of fun! We went from nowhere to first place with
  $12,000 in donations for Feeding America. But we were so successful
  that we actually have a chance to win, which means that we can't
  just stop now. So this post is about what has happened over the weekend and what comes next.

<p>

First, of course: <a href="http://crowdrise.com/TeamJS">Please give</a>
  if you haven't yet, and please keep publicizing this good cause.

<p>

As of 9:30pm on Sunday, we had raised $12,211 from 84 donors. The
(skewed) average donation was $145. The mode was $100 and the median
was $50.

<img src="http://davidflanagan.com/TeamJS/histogram121811.png">

<p>
I've discovered that Feeding America has
some <a href="http://www.youtube.com/user/feedingamerica">really
well-done videos</a> that explain the hunger problem in America and
what they're doing to address it. I've linked to my favorites from the
<a href="http://crowdrise.com/TeamJS">TeamJS page at crowdrise.com</a>


<p>

Speaking of the <a href="http://crowdrise.com/TeamJS">TeamJS page</a>,
I've I've made some changes to it:

<ul>
<li>It includes more information about Feeding America, including the
  videos mentioned above
<li>It includes a bit of information about what "JS" is, since now
  that we're in first place, I expect that non-geeks will be clicking
  through to our page.
<li>I've upload JSconf and Jupiter Consulting logos to the page and
  they display as small icons beneath the big JavaScript logo, in
  recognition of the major gifts from those two businesses. (There are
  three spots left on the page: if you've got a business, a $1000
  donation will get your logo on the page, until some other business
  gives more and knocks you out of the spot.)
</ul>

<p>
I've got to hand it to <a href="http://crowdrise.com">crowdrise</a>:
they do a great job at online giving. I don't like that I have to
reload the entire page to check for new donations, but the site is
responsive and they do imbue the whole process with a sense of fun!

<p>
I've noticed that many donors (about a third or so) are creating
crowdrise accounts and formally joining TeamJS as a fundraiser.
That's great.  Anyone who does that can use their own page as a
donation URL to publicize and gets public credit for the donations
they've brought in.  You can post a photo, and you can participate in team discussions on the site, if we ever have any. But you don't have to do that to be part of
TeamJS. If you donate, you're part of the team!

<p>
We're comfortably ahead for now, but I don't think we can dismiss the
competition. These are people with hundreds of thousands of twitter
followers, and they haven't really gotten serious yet. Also, three of
the celebrites are old hands at fundraising on crowdrise.  Barbra
Streisand, Sophia Bush, and Ed Norton
are <a href="http://www.crowdrise.com/community/vote/all">the #2, #3
and #4 all-time biggest fundraisers on the site</a>. So we should
expect them to come on strong. (And if they do come on strong, it is in part because we've forced them to work harder, and everybody's cause wins!)

<p>
So what's next? How can we keep the momentum going? Please share your
ideas in comments, by email, on twitter, or on the crowdrise
site. Should we have a TeamJS presence on Facebook or Google+? Go for
it! Can we get other programming language communities involved? Can we
attract other business donations? Can we broaden the appeal of the campaign beyond the tech community? Everyone one is welcome to dive in
and help in whatever way you can!
]]>
        
    </content>
</entry>

<entry>
    <title>Read This or I&apos;m Switching to PHP</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/12/read-this-or-im.html" />
    <id>tag:www.davidflanagan.com,2011://1.218</id>

    <published>2011-12-16T17:51:55Z</published>
    <updated>2011-12-27T18:15:41Z</updated>

    <summary> (If you don&apos;t live in the US, you can skip it.) The US Census Bureau calculates that in 2008, 15% of US households were &quot;food insecure&quot;. A slightly older version of that data is broken down by county and...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>
(If you don't live in the US, you can skip it.)
<p>
The US Census Bureau calculates that in 2008, <a
href="http://www.census.gov/compendia/statab/2011/tables/11s0210.pdf">15%
of US households were "food insecure"</a>.  A slightly older version
of that data is broken down by county and state in <a
href="http://feedingamerica.org/hunger-in-america/hunger-studies/map-the-meal-gap.aspx">this
excellent interactive map</a>.
<p>
With continued high unemployment, that 15% figure has surely gone up
since 2008. These are the households that may have to choose between
food and heat this winter.  If, like me, you can't even imagine what
it must be like to have to make that choice, you're probably in a
position to help.
<p>
Its just crazy that there's a major hunger problem in a country with
huge food surpluses. That's why one of my favorite charities is <a
href="http://feedingamerica.org">Feeding America</a> (you may have heard of
them under their old name "America's Second Harvest). They're a
national organization that collects surplus before it is thrown out
and distributes it to a network of food banks that distribute it to
people in need.  
<p>
And they're very efficient at it: each dollar donated provides eight
meals. And they've got very low administrative and fundraising
overhead: 96% of their money goes to their hunger programs.
<p>
Please help, if you can.
<p>
And if you're going to donate money to Feeding America, a fun way to
do it is to participate in the <a
href="http://crowdrise.com/firefoxchallenge">Mozilla Firefox
Challenge</a> as part of <a
href="http://crowdrise.com/TeamJS">TeamJS</a>: I'm challenging the US
JavaScript and webdev community to donate more to this cause than a
dozen Hollywood celebrities can raise for their causes. I think it
would be great to see the bright yellow JS logo (and the Rhinoceros
from my book because I think it is funny :-) in the middle of that pack
of celebs.  (Click on the Firefox Challenge link above for a visual of
what I'm talking about.)
<p>
I've been flogging this pretty hard on Twitter (#teamjs and
#fxchallenge), <s>with fairly disappointing results. I'm not ready to
give up, but I am feeling discouraged,</s> and I could really use some
help. If you think the challenge is a fun way to raise money for a
good cause, please help publicize it. I don't use Facebook or Google+,
so help with those networks would be especially great. If you sign up
for an account on crowdrise.com, you can even join the TeamJS team.
<p>
<b>Update</b>: discouraged no more! Chris Williams and JSConf have made a big donation and a huge publicity push.  TeamJS is now in 4th place!
<p>
And if you don't live in the US (but read this anyway) and would like
to raise money for a cause that is not US-centric, you can create an
account at crowdrise.com and then create your own team in the Firefox
Challenge-maybe you can embarrass the US JavaScript community into
giving more!
]]>
        
    </content>
</entry>

<entry>
    <title>Geeks vs. Celebs: The Mozilla Firefox Challenge and TeamJS</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/12/geeks-vs-celebs.html" />
    <id>tag:www.davidflanagan.com,2011://1.217</id>

    <published>2011-12-15T06:37:43Z</published>
    <updated>2012-01-08T16:06:01Z</updated>

    <summary>Mozilla is sponsoring The Mozilla Firefox Challenge, a celebrity fundraiser. Mozilla has donated $5000 to the favorite charity of 12 Hollywood celebrities and will donate $25,000 more to the charity of whichever celebrity can raise the most for their cause....</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>Mozilla is sponsoring <a href="http://crowdrise.com/firefoxchallenge">The Mozilla Firefox Challenge</a>, a celebrity fundraiser.  Mozilla has donated $5000 to the favorite charity of 12 Hollywood celebrities and will donate $25,000 more to the charity of whichever celebrity can raise the most for their cause.</p>

<p>I want to challenge the JavaScript community, and the web developer community, and heck, the whole geek community to go head to head with the celebrities and raise more money than they can.  So I've formed <a href="http://crowdrise.com/TeamJS">TeamJS</a> to compete against the celebs in the challenge. We don't get the head start of $5k seed money, but we can still win the $25K prize!</p>

<p>The charity I've picked is <a href="http://feedingamerica.org">Feeding America</a>, which describes itself as a sort of food bank for food banks.  They're a national organization that collects surplus food and distributes it, via a network of independent food banks, to those who are hungry.  And they're remarkably efficient at what they do: each dollar donated provides 8 meals.</p>

<p>I kicked things off with a $500 donation. Please contribute what you can, and spread the word!</p>

<p>(Feeding America is a US charity, but the international JavaScript community is more than welcome to participate.  I've asked crowdrise if they'll allow me to designate different charities on different days, so we can pick others that appeal to geeks in other parts of the world, but I don't actually know if that will be possible. </p>

<p><b>Update</b>: crowdrise.com says that I can't switch charities once donations have been made.  If you want to participate but want to give to a different charity, you can form a new team.  TeamJS.eu anyone?  Since crowdrise is in the US, the charities have to be registered in the US, but that still leaves lots of good ones with an international focus... )</p>]]>
        
    </content>
</entry>

<entry>
    <title>IndexedDB demo</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/11/indexeddb-demo.html" />
    <id>tag:www.davidflanagan.com,2011://1.216</id>

    <published>2011-11-23T00:08:14Z</published>
    <updated>2011-11-23T00:14:02Z</updated>

    <summary>Back in January I posted an IndexedDB example that showed how to initialize and query a database of zipcodes using the HTML5 IndexedDB API. That API has been evolving, and Kyle Huey from Mozilla has updated my example to work...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>Back in January I posted <a href="http://www.davidflanagan.com/2011/01/indexeddb-statu.html">an IndexedDB</a> example that showed how to initialize and query a database of zipcodes using the HTML5 IndexedDB API.</p>

<p>That API has been evolving, and Kyle Huey from Mozilla has updated my example to work with the latest version of the API, which is implemented in Firefox 10. The main difference seems to be in the way that the database is initialized.  Instead of the old setVersion() magic, you now set up the database in the handler of the "upgradeneeded" event. <br />
That's quite a bit more sensible.</p>

<p>Kyle's version of the demo is <a href="http://people.mozilla.org/~khuey/idb-demo/demo.html">here</a>. The first query you make triggers the initialization of the database.  It looks like there might be a problem with that first query not succeeding.  But subsequent queries do work.</p>

<p>Thanks Kyle!</p>]]>
        
    </content>
</entry>

<entry>
    <title>Why I want Classes in JavaScript</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/11/why-i-want-clas.html" />
    <id>tag:www.davidflanagan.com,2011://1.215</id>

    <published>2011-11-14T20:49:48Z</published>
    <updated>2011-11-29T04:32:44Z</updated>

    <summary> I had a little twitter rant this morning about classes in JavaScript. (Actually, the rant was really about the attitude that seems to be behind much of the &quot;don&apos;t add classes to JavaScript&quot; commentary I see.) So I should...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p> I had a little <a
href="https://twitter.com/#!/__DavidFlanagan/status/136132446285606912">twitter</a>
<a
href="https://twitter.com/#!/__DavidFlanagan/status/136132851484721153">rant</a>
this morning about classes in JavaScript. (Actually, the rant was
really about the attitude that seems to be behind much of the "don't
add classes to JavaScript" commentary I see.) So I should probably
explain in somewhat longer form why I want classes added to the language.

<ul>
<li>The JS standard library is object oriented: we write a.map(f), not
map(a,f). If the standard library defines classes, the language should
make it easy to define classes.

<li>A number of popular JS libraries include convenience methods for
defining and/or extending classes.  This demonstrates to me that
developers want to use classes and JavaScript, but that they want a
simpler way to define them.

<li>Once we get used to the idea of a class keyword in the language, I
think it is going to be really nice to be able to dash off little
classes with that keyword, instead of the two step define the
constructor and then set up its prototype object technique that we use
now. In particular, I think it is going to feel really old-fashioned
to define classes the old way once we've got modules in the language.
I can't articulate this point well, but it is actually the one that is
most compelling to me.  We're getting modules in the next version of
JS, and I don't think that the language will feel right without a
class syntax to go along.  

<li>The classes being proposed for JavaScript are all syntax sugar for
existing patterns.  Adding a class keyword will not change JS in any
fundamental way, it will just make it easier to use the patterns that
we already use.  If you like defining your classes the old way, you'll
still be able to do that.  And you'll still be able to add methods to
classes with C.prototype.new_method = function() {...} as you can
today. As Brendan Eich would say, this is just "paving the cow
paths". Here's what the <a href ="http://wiki.ecmascript.org/doku.php?id=harmony:classes">classes proposal</a> [<b>Update link fixed now</b>] describes as its motivation: 
<blockquote>
ECMAScript already has excellent features for defining abstractions
for kinds of things. The trinity of constructor functions, prototypes,
and instances are more than adequate for solving the problems that
classes solve in other languages. The intent of this strawman is not
to change those semantics. Instead, it's to provide a terse and
declarative surface for those semantics so that programmer intent is
expressed instead of the underlying imperative machinery. 
</blockquote>
</ol>

<p> 
I understand the reluctance that  many JS programmers feel about
adding classes.  I feel it too, a little bit. A class keyword isn't
"javascripty". I like, and understand the appeal of Allen
Wirfs-Brock's approach: He defines extensions that make object
literals more expressive, and then uses the &lt;| and {. operators to
create a simple class definition pattern. But the problem is that it
is still a pattern rather than a new syntactic form. And to quote
Dave Herman: "patterns are the sincerest form of feature request": if
we're using patterns to define classes, then the language ought to
just support classes.

<p> My desire to have classes in the next version of JavaScript of
course has no bearing on whether we'll actually get them.  The classes
proposal linked above is apparently not doing well in committee, for
reasons that I haven't tried to understand.  There have been recent
attempts to revive classes with <a
href="https://gist.github.com/1329619">simpler</a> <a
href="http://wiki.ecmascript.org/doku.php?id=strawman:minimal_classes">class</a>
<a href="https://gist.github.com/1332193">proposals</a>, so maybe
there is still some hope.

]]>
        
    </content>
</entry>

<entry>
    <title>Code coverage for improving test suites</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/11/code-coverage-f.html" />
    <id>tag:www.davidflanagan.com,2011://1.214</id>

    <published>2011-11-11T23:08:57Z</published>
    <updated>2011-11-29T04:33:29Z</updated>

    <summary>I&apos;ve recently blogged about CoverMonkey, a code coverage tool for Mozilla&apos;s SpiderMonkey JavaScript interpreter and my JavaScript HTML parser. One of the really useful things you can do with a code coverage tool is check whether your test suites are...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>I've recently blogged about <a href="http://www.davidflanagan.com/2011/08/covermonkey-cod.html">CoverMonkey</a>, a code coverage tool for Mozilla's SpiderMonkey JavaScript interpreter and my JavaScript <a href="http://www.davidflanagan.com/2011/10/html-parsing-wi.html">HTML parser</a>.</p>

<p>One of the really useful things you can do with a code coverage tool is check whether your test suites are actually exercising all of the code you're trying to test.  (A hat tip here to my colleague Donovan Preston who insisted on good tests for <a href="https://github.com/andreasgal/dom.js">dom.js</a>-CoverMonkey was his idea.)  There is already a very good <a href="http://code.google.com/p/html5lib/source/browse/#hg%2Ftestdata">test suite for HTML parsers</a> and I was able to get my HTML parser to pass those tests.</p>

<p>That test suite is large and comprehensive, but when I ran CoverMonkey over the tests I found that there about 100 lines (out of some 5000) in my parser that did not get run by the tests.  These were for pretty obscure things.  Like what happens if you put a &lt;!DOCTYPE&gt; after &lt;body&gt;, or what happens if you have a NUL (\u0000) character in a &lt;script&gt; tag or what if you use &amp;NotEqualTilde; character reference, which expands to two 16-bit characters rather than just one) in RCDATA state (like in a &lt;xmp&gt; element) ?</p>

<p>I ended up writing 65 test cases to improve code coverage for my parser up to almost 100%.  (There is still some untested code for handling &lt;noscript&gt; tags when scripting is disabled because the way the test suite is set up does not allow testing with scripting disabled).  Anne van Kesteren was kind enough to grant me commit rights to the html5lib repo, and my tests are now part of the suite: <a href="http://code.google.com/p/html5lib/source/browse/testdata/tokenizer/domjs.test">here</a> and <a href="http://code.google.com/p/html5lib/source/browse/testdata/tree-construction/domjs-unsafe.dat">here</a>.</p>

<p>I'm pretty pleased with this.  It is a small thing, and there are only a handful of developers who will ever need to run these particular tests, but being able to use CoverMonkey to find and fix these few remaining holes in an otherwise excellent set of tests was pretty cool.  </p>

<p>(If you are one of those handful of developers who might actually run these tests, note that my parser does not do validation and does not report parse errors. My tokenizer test cases include parse errors where I think they should be reported, but I can't actually verify with my own parser that there are supposed to be errors in those spots. So the tokenizer tests might have errors related to error reporting.  The parser test cases also do not include any errors, but I doubt that will break things for anyone, since the errors in the parser tests aren't standardized in any way and can't really be compared.)</p>

<p>So, the moral of the story is: validating your test suites with a code coverage tool really works!</p>]]>
        
    </content>
</entry>

<entry>
    <title>HTML Parsing with JavaScript</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/10/html-parsing-wi.html" />
    <id>tag:www.davidflanagan.com,2011://1.213</id>

    <published>2011-10-27T06:21:53Z</published>
    <updated>2011-11-29T04:38:24Z</updated>

    <summary> The project I&apos;ve been working on in Mozilla&apos;s research group is dom.js: an implementation of the browser DOM in JavaScript. I&apos;ve gotten much of the core DOM 4 document tree functionality implemented, and have started on DOM features defined...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>
The project I've been working on in Mozilla's research group is 
<a href="http://github.com/andreasgal/dom.js">dom.js</a>: an
implementation of the browser DOM in JavaScript. I've gotten much of
the core
<a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html">DOM
4</a> document tree functionality implemented, and have started on DOM
features defined by the HTML spec.
<p>
One of those features is the innerHTML property. And to implement it,
I need an HTML parser. So I dove in and implemented one.  Here are
some of the things I learned:]]>
        <![CDATA[<ul>
<li>Long ago, browser vendors made the choice that browsers would not
  display error messages when given malformed HTML, but instead
  attempt to display the malformed input in some reasonable way. For
  web compatibility, all browsers today must do that. XHTML was a
  attempt at imposing a strict syntax on the web, and it failed.

<li>So for web compatibility, browsers must all parse HTML liberally
  and accept malformed input. And for web interoperability, browsers
  must all parse malformed HTML <i>in the same way</i>.

<li>The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html">HTML
  parsing specification</a> is long and complicated. This is because
  in addition to specifying exactly how to parse valid HTML inputs, it
  also specifies exactly how to parse all possible invalid inputs. A
  standardized parsing algorithm is, in fact, one of the most
  important (but least appreciated) features of HTML 5 and represents
  a huge amount of work by Ian Hickson.

<li>The HTML spec defines the parser in terms of a tokenizer stage and
  a tree builder stage.  And both stages are defined as state machines
  (which you may remember from undergrad CS classes). The prose
  description of a state machine is verbose, but the translation to
  JavaScript code is fairly mechanical (in fact, I wrote a simple
  script to help me translate most of the tokenizer state machine from
  HTML prose to JavaScript code).  

<li>The advantage of a state machine specification is that it can
  account for every possible input.  What happens, for example, when
  the tokenizer sees &lt;a href=&gt;, for example, or reaches the
  end-of-file while in the middle of a comment? Since the tokenizer is
  specified as a state machine unexpected inputs like these are just
  state transitions and have a well-defined behavior.

<li>The flip side is that by specifying the HTML parser in terms of
  state machines, the HTML spec never explicitly says how the parser
  is supposed to behave when it is given &lt;a href=&gt; or other
  malformed input. The behavior is implicit in the transitions of the
  state machine, but to figure out what the parser does for any given
  input, you have to read through the spec, simulating the state
  machines in your head.  There is not a formal grammar like you'd see
  when reading a programming language specification, just an
  algorithmic description of how the parser behaves.

<li>The HTML specification includes specific instructions on how to
  handle the &lt;/sarcasm&gt; end tag. I think its a joke, though,
  since the instructions say to treat it like any other end tag. :-)

<li>The HTML specification integrates the SVG and MathML grammars, and
  as part of that, HTML adopts all the named character entities
  (things like &amp;lt; and &amp;quot;) of MathML.  There are now 2125
  named character references you can use, including
  &amp;CounterClockwiseContourIntegral; and &amp;InvisibleComma;!

<li>An HTML parser implementation cannot be separated from the HTML
  and DOM implementation of which it is a part. I had always assumed
  that an HTML parser could be written generically to build up a DOM
  parse tree using public DOM APIs like document.createElement() and
  Element.appendChild(). It turns out that there are a number of
  places where the parser must manipulate DOM nodes in ways that are
  not possible with the public API. These include setting the
  compatMode property of the Document object and setting the form
  property of HTML form elements like input fields and buttons.

<li>There is a really nice HTML parsing
  <a href="http://code.google.com/p/html5lib/source/browse/#hg%2Ftestdata">
    test suite
  </a> (the tokenizer and tree-construction directories are the most
  important ones) and I gather that the major browser vendors all use
  it. Strangely, the documentation for using the test data is at a
  <a href="http://wiki.whatwg.org/wiki/Parser_tests">completely
  different site</a>.
</ul>

<p>
It took me a couple of weeks, but I learned a lot about HTML parsing
and ended up with a working parser! The
<a href="https://github.com/andreasgal/dom.js/blob/master/src/impl/HTMLParser.js">
source code</a> weighs in at over a quarter megabyte and 6300 sloc. (Though to be fair, I should note that the object literal that holds those 2125 named character references takes up over 1000 of those lines of code.) It
passes the tokenizer and tree construction tests mentioned above, and
it can parse the HTML specification (over 6 megabytes of HTML) in
under 8 seconds.

<p>
If I can brag a bit, this 8 second speed easily beats the two other
JavaScript-based HTML parsers that I know of.  The Node-based parser
at https://github.com/aredridel/html5 displays some kind of quadratic
behavior (doubling the size of the HTML to be parsed quadruples the
parsing time) and as far as I can tell (I gave up after 5 minutes or
so) it is just not capable of parsing the HTML spec, at least not when
used with the Node-based DOM library at
https://github.com/tmpvar/jsdom.

<p>
The other JavaScript HTML parser I know about is
the <a href="http://about.validator.nu/htmlparser/">Validator.nu</a>
parser by my Mozilla colleague Henri Sivonen.  This is a Java-based
parser, but it includes a custom Java-to-C++ translator, and when
translated to C++, it is used as Firefox's HTML parser.  The same
codebase can be translated to JavaScript using Google's GWT parser,
but the result is not terribly efficient.  Parsing the HTML
specification takes 18 to 20 seconds with the GWT version of Henri's
parser.  (I thought seriously about modifying Henri's Java-to-C++
translator to output JavaScript instead of C++, but in the end, I
decided that it would take a similar amount of time and would be more
fun and educational to just write my parser from scratch.)

<p>
If you've read this far, here is where I confess that my parser isn't
even done yet. It does not yet execute scripts, which means that it
doesn't handle document.write() calls.  That's next on my list, but
its kind of scary.  You'd think that executing a script in a
JavaScript-based parser would just amount to an eval() call.  But
there's
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-incdata">a</a>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#execute-the-script-block">lot</a>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#prepare-a-script">more</a>
to it than that.  Another colleague of mine described these sections
of the spec as "brain-meltingly" complex.  We'll see.  I'm keeping my
fingers crossed that none of the strange cases where document.write()
inserts new scripts require me to refactor the parsing code in major
ways!
]]>
    </content>
</entry>

<entry>
    <title>Too much comment spam</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/09/too-much-commen.html" />
    <id>tag:www.davidflanagan.com,2011://1.212</id>

    <published>2011-09-05T06:08:57Z</published>
    <updated>2011-09-05T06:16:25Z</updated>

    <summary>I&apos;ve turned off comments for all entries on this blog, since I had over a thousand spam comments over the last couple of weeks. Most of them never got published, but dealing with even the small fraction that got through...</summary>
    <author>
        <name>David</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>I've turned off comments for all entries on this blog, since I had over a thousand spam comments over the last couple of weeks.  Most of them never got published, but dealing with even the small fraction that got through the comment spam filters was too much work.<br />
I think the problem was that I hadn't been closing old comment threads, so the blog presented a good target to comment spammers.  Maybe now if I just leave the comments open for the most recent one or two entries the spam problem won't be so bad.</p>]]>
        
    </content>
</entry>

<entry>
    <title>CoverMonkey: code coverage for SpiderMonkey</title>
    <link rel="alternate" type="text/html" href="http://www.davidflanagan.com/2011/08/covermonkey-cod.html" />
    <id>tag:www.davidflanagan.com,2011://1.211</id>

    <published>2011-08-21T15:11:43Z</published>
    <updated>2011-08-21T15:43:32Z</updated>

    <summary>I started work at Mozilla in May, and haven&apos;t had a chance to update my blog since then. I&apos;ve been working on a project to implement the DOM in JavaScript. One of the interesting side-projects that has come out of...</summary>
    <author>
        <name>David</name>
        
    </author>
    
        <category term="javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.davidflanagan.com/">
        <![CDATA[<p>I started work at Mozilla in May, and haven't had a chance to update my blog since then.  I've been working on <a href="https://github.com/andreasgal/dom.js">a project to implement the DOM in JavaScript</a>.  One of the interesting side-projects that has come out of this is a code coverage tool for SpiderMonkey (Mozilla's js interpreter).  I'm calling it CoverMonkey, and have just created a <a href="https://github.com/davidflanagan/CoverMonkey">repo for it on github</a>.  Take a look at some <a href="https://github.com/davidflanagan/CoverMonkey/blob/master/screenshot.png">example output</a>.</p>

<p>Debug builds of SpiderMonkey have a -D option that causes them to output opcode-by-opcode disassembly of every file they've run, along with execution counts for every opcode.  CoverMonkey analyzes this output and displays coverage statistics and generates color-coded versions of your source code to highlight uncovered and partially covered lines. </p>

<p>The first big caveat about CoverMonkey is that this is not a tool you can use in the browser.  It works with standalone versions of SpiderMonkey only.  So it is only useful if you're using pure JavaScript.  The second caveat is that you'll need a debug build of SpiderMonkey, which means that you'll probably have to <a href="https://developer.mozilla.org/En/SpiderMonkey/Build_Documentation">build it yourself</a>. Another, smaller caveat: CoverMonkey is a JavaScript program, but unfortunately SpiderMonkey cannot create files, so CoverMonkey requires Node.<br />
</p>]]>
        
    </content>
</entry>

</feed>

