<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Infrequently Noted &#187; javascript</title>
	<atom:link href="http://infrequently.org/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://infrequently.org</link>
	<description></description>
	<lastBuildDate>Fri, 18 Nov 2011 16:25:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Real Constructors &amp; WebIDL Last Call</title>
		<link>http://infrequently.org/2011/10/real-constructors-webidl-last-call/</link>
		<comments>http://infrequently.org/2011/10/real-constructors-webidl-last-call/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 14:10:03 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://infrequently.org/?p=1693</guid>
		<description><![CDATA[For those who haven&#8217;t been following the progress of WebIDL &#8212; and really, how could you not? An IDL? For the web? I&#8217;d like to subscribe to your newsletter&#8230; &#8212; the standard is now in last call, which is W3C for &#8220;alllllllllllmost done&#8221;. Which it is not. Before I get to why, let me first [...]]]></description>
			<content:encoded><![CDATA[<p>For those who haven&#8217;t been following the progress of WebIDL &#8212; and really, how could you not? An IDL? For the web? I&#8217;d like to subscribe to your newsletter&#8230; &#8212; the standard is now in <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">last call</a>, which is W3C for &#8220;<em>alllllllllllmost</em> done&#8221;.</p>
<p>Which it is not.</p>
<p>Before I get to why, let me first say some nice, well-earned things about WebIDL: first, it has helped us out of the ad-hoc IDL sludge that used to be how APIs for JavaScript have been exposed in the past. It has shaved off many sharp edges and is giving spec authors a single dialect in which to write their API descriptions. From a browser perspective, this is a <em>Very</em> Good Thing (TM). Next, the draft in question contains some wonderful changes from the status quo, particularly the <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/#interface-prototype-object">addition of a sane prototype to all WebIDL-specified objects</a>.</p>
<p>That all sounds good, so what&#8217;s missing?</p>
<p>In a word, constructors.</p>
<p>Well, a lot more than that, but I&#8217;d settle for constructors. Functionally speaking, it boils down to the fact that WebIDL makes spec authors do extra work to make something like this sane:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">new</span> HTMLDivElement<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Why doesn&#8217;t this work today? Funny story&#8230;see, HTML defines <a href="http://www.w3.org/TR/html5/grouping-content.html#htmldivelement">HTMLDivElement</a> as a regular WebIDL interface. WebIDL doesn&#8217;t really have the notion of concrete classes, just interfaces with and without constructors. Since the HTML spec is just doing what most specs will do &#8212; adding the smallest IDL you can get away with &#8212; the JS usability of this API is left in limbo; neither clearly HTML5&#8242;s responsibility nor WebIDL&#8217;s.</p>
<p>So what should a contentious version of HTML5 do? One answer is to specify a constructor, turning the IDL from this:</p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;"><span style="color: #990078; font-weight: bold">interface</span> HTMLDivElement <span style="color: #66cc66;">:</span> HTMLElement <span style="color: #808080;">&#123;</span><span style="color: #808080;">&#125;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>to this:</p>

<div class="wp_syntax"><div class="code"><pre class="idl" style="font-family:monospace;"><span style="color: #808080;">&#91;</span>Constructor<span style="color: #808080;">&#93;</span>
<span style="color: #990078; font-weight: bold">interface</span> HTMLDivElement <span style="color: #66cc66;">:</span> HTMLElement <span style="color: #808080;">&#123;</span><span style="color: #808080;">&#125;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>Repeat ad-infinitum for each and every interface that <em>should</em> be constructable in every single spec that browser vendors ever implement. Don&#8217;t miss any! And please make sure that all your spec editors are on-board with good JS APIs as a goal! As it stands today, WebIDL doesn&#8217;t even force most spec authors to consider the question &#8220;do I need a constructor here?&#8221; &#8212; spoiler: <em>yes</em> &#8212; let alone the obvious follow-ups like &#8220;what arguments should one take?&#8221;.</p>
<p>The obvious better answer here is to flip the default on interfaces, causing them to generate constructors by default unless turned off with <code>[NoConstructor]</code> attributes or specified as <code>partial</code> interfaces (i.e., mixins or traits).</p>
<p>Cameron McCormack who is heading up the WebIDL effort <a href="http://twitter.com/#!/heycam/status/118784862164484096">tweeted in response to my exasperation</a> that:</p>
<blockquote><p>I think a &#8220;W3C Web API design guidelines&#8221; document would be a perfect place for such a recommendation.</p></blockquote>
<p>For serious? Such a document might be useful (and I&#8217;m working on something that might pass as a first draft), but what&#8217;s the argument against flipping the default here? This isn&#8217;t a dissent on the facts of the situation: most WebIDL &#8220;interfaces&#8221; that are exposed to JS are things that could be easily <code>new</code>&#8216;d up to useful ends. Most specs flub this in spectacular style. Most spec authors seem entirely ignorant of the problem and the design language of WebIDL continues to lead down a primrose copy-and-paste path that has little overlap with sanity. So why punt the decision? And why did it take and act of coordination with TC39 to get the prototype thing fixed?</p>
<h3>And Why Are We Having This Discussion Anyway?</h3>
<p>WebIDL, for all of its virtues, is deeply confused.</p>
<p>If you&#8217;re reading any of the stuff in the HTML5 spec that&#8217;s describing its API this way, it&#8217;s hard to see how it would have any sane relationship to JavaScript. Sure, you could argue that there might be other languages that matter, other languages for which you&#8217;d need to be able to generate some API, but none of them rise to anything like the importance of JavaScript. It <em>is</em> the programming language of the web, so if WebIDL has any animating force at all, it&#8217;s JS. Then there&#8217;s the &#8220;accident of history&#8221; aspect. Early DOM was specified as a form of IDL in part because there was some expectation that other languages would need to consume it and IDL was how C++ hackers (who still make up the entire set of people working on browser engines) are/were comfortable in describing their FFIs thanks to the legacy of COM/CORBA. <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/#java-binding">Hilarious examples of multi-language-ism still persist in the WebIDL spec</a> for no apparent reason whatsoever, warping the entire design around the altar of an ideal that is either quixotic or vestigial depending on which argument you give more weight. </p>
<p><a href="http://lists.w3.org/Archives/Public/public-script-coord/2011JulSep/thread.html#msg114">Since the debate was re-kindled thanks to a debate at a TC39 meeting in July</a>, I&#8217;ve been on the receiving end of more than one webdev&#8217;s rant about DOM&#8217;s JS incoherence, generally taking the form:</p>
<blockquote><p>Why the *#!*?^@$ isn&#8217;t DOM just #@!*@ing specified in JavaScript?</p></blockquote>
<p>To be honest, I have no answer aside from pointing to the IDL history, the fact that browser hackers don&#8217;t tend to write JS so don&#8217;t feel the pain, and noting that WebIDL <em>is</em> better in some important ways. Certainly these interfaces <em>could</em> be specified in a subset of JS with annotations for where native behavior is required. But their larger lament has merit too: seamlessness with JS is the bar WebIDL should be judged by. I.e. does it help spec authors do the right thing by JS devs? Or does it lead them down paths that make their generated APIs stick out like sore thumbs, full of anti-social/alien behavior such that you can&#8217;t think of them as &#8220;regular&#8221; JS?</p>
<p>Yes, constructors are only one minor step toward reaching this aspiration, but the fact that WebIDL has gotten to last-call without a reasonable solution to them speak volumes. If WebIDL <em>isn&#8217;t</em> animated by the need of JS developers, it would be good if that could be loudly called out somewhere so that the community can have the spirited debate that this point demands. If it is, can we please get on discussing how best to ensure that most &#8220;interfaces&#8221; generate constructors and stop punting?</p>
<p>Either way, WebIDL isn&#8217;t done yet.</p>
<p><b>Update:</b> It occurred to me, as part of the discussion in the comments, that the provision against <code>new</code> with a class or type of any type is completely non-sensical in JS, as is the lack of <code>call()</code> and <code>apply()</code> methods on them. Idiomatic subclassing requires that the mixin-style be available, which uses <code>ClassName.call(this)</code>. This is what you&#8217;d do with things that are &#8220;virtual&#8221; or &#8220;partial&#8221; interfaces if you&#8217;re describing them in actual JS. And there&#8217;s no real problem with folks <code>new</code>-ing them up. Doesn&#8217;t happen, doesn&#8217;t matter. Strong restrictions against it are, to quote Andrew DuPont, anti-social. Long story short: <b><em>there is absolutely no reason whatsoever to disable construction on any WebIDL interface. It&#8217;s deeply non-sensical from the JavaScript perspective.</em></b></p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2011/10/real-constructors-webidl-last-call/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Cutting The Interrogation Short</title>
		<link>http://infrequently.org/2011/01/cutting-the-interrogation-short/</link>
		<comments>http://infrequently.org/2011/01/cutting-the-interrogation-short/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 22:21:04 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://infrequently.org/?p=1560</guid>
		<description><![CDATA[I&#8217;ve been having a several-day mail, IRC, and twitter discussion with various folks about performance and the feature detection religion technique, particularly on mobile where CPU ain&#8217;t free. So what&#8217;s the debate? I say you shouldn&#8217;t be running tests in UA&#8217;s where you can dependably know the answer a-priori. Wait, what? Why does Alex Russell [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having a several-day mail, IRC, and twitter discussion with various folks about performance and the feature detection <strike>religion</strike> technique, particularly on mobile where CPU ain&#8217;t free. So what&#8217;s the debate? I say you shouldn&#8217;t be running tests in UA&#8217;s where you can dependably know the answer a-priori.</p>
<p>Wait, what? Why does Alex Russell hate feature testing, kittens, and cute fuzzy ducklings?</p>
<p>I don&#8217;t. <a href="http://paulirish.com/">Paul</a> warned me that my approach isn&#8217;t going to be popular at first glance, but hear me out. My assumptions are as follows:</p>
<ul>
<li>Working is better than busted</li>
<li>Fast is better than slow</li>
<li>No browser vendor changes the web-facing features in a given version. Evar. Does not happen</li>
</ul>
<p>If you buy those, then I think we can all get some satisfaction by retracing our steps and asking, seriously, what <em>is</em> the point of feature testing?</p>
<p>Ok, I&#8217;ll go first: feature testing is motivated by a desire not to be busted, particularly in the face of new versions of UA&#8217;s which will (hopefully) improve standards support and reduce the need for hacks in the first place. Sensible enough. Why should users wait for a new version of your library just &#8217;cause a new browser was released or because you didn&#8217;t test on some version of something.</p>
<p>Extra bonus: if you don&#8217;t mind running them every time, you can write just the feature test and your work is done now and in the future! Awesome! Except some of us do mind. Yes, things are now resilient in the face of new UA&#8217;s and new versions of old ones, but only on the back of testing for everything you need ever time you load a library on a page. Slowly. Veeerrrrry slooowly.</p>
<p>Paul suggested that some library could use something like Local Storage to cache the results of these tests locally, but this hardly seems like an answer. First, what if the user upgrades their browser? Guess you have to cache and check against the UA string anyway. And what about the cost of going to storage? Paul reported that these tests can be <em>wicked</em> expensive to run at all, on the order of 30ms for the full suite (which you hopefully won&#8217;t hit&#8230;but sheesh). Reported worst-case for <a href="https://github.com/phiggins42/has.js/">has.js</a> is even worse. But apparently going to Local Storage is <em>also</em> expensive. And we&#8217;re still running all these tests in the fast path the first time anyway. If we think that they&#8217;re so expensive that we want to cache the results, why don&#8217;t we think they&#8217;re so expensive that we don&#8217;t want to run them in the common case?</p>
<p>Now for a modest proposal: <b>feature tests should only ever be run <em>when you don&#8217;t know what UA you&#8217;re running in</em></b>.</p>
<p>Feature testing libraries should contain pre-built caches &#8212; the kind that come with the library, not the kind that get built on the client &#8212; but they should only be consulted for UA versions that you <em>know</em> you know. If we assume that behavior for UA/version combination never changes, we&#8217;ve got ourselves a get-out-of-jail free card. Libraries can have <code>O(1)</code> behavior in the common case and in the situations where feature testing would keep you from being busted, you&#8217;re still not busted.</p>
<p>So what&#8217;s the cost to this? Frankly, given the size of some of the feature tests I&#8217;ve seen, it&#8217;s going to be pretty minimal vs. the bloat the feature tests add. All performance work is always a tradeoff, but if your library thinks it&#8217;s important not to break <em>and</em> to be fast, then I don&#8217;t see many alternatives. New versions of libraries can continue to update the caches and tests as necessary, keeping the majority of users fast, while at the same time keeping things working in hostile or unknown environments.</p>
<p>Anyhow, if you&#8217;re a library author or maintainer, please please <em>please</em> consider the costs of feature tests, particularly the sort that mangle DOM and or read-back computed layout values. Going slow hurts users, hurts the web, and hurts the culture of performance that&#8217;s so critical to keeping the platform a viable contender for the next generation of apps. We owe it to users to go faster.</p>
<p><b>A quick aside</b>: I hesitated writing this for the same reasons that Paul cautioned me about how unpopular this was going to be: there&#8217;s a whole lot of know-nothing advocacy that&#8217;s still happening in the JS/webdev/design world these days, and it annoys me to no end. I&#8217;m not sure how our community got so religious and fact-disoriented, but it has got to stop. If you read this and your takeaway was &#8220;Alex Russell is against feature testing&#8221;, then you&#8217;re part of the problem. Think of it like a feature test for bogosity. Did you pass? If so, congrats, and thanks for being part of the bits of the JavaScript universe that I like.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2011/01/cutting-the-interrogation-short/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>JavaScript UXO Removal Updated</title>
		<link>http://infrequently.org/2010/09/javascript-uxo-removal/</link>
		<comments>http://infrequently.org/2010/09/javascript-uxo-removal/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 21:07:00 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[dom]]></category>

		<guid isPermaLink="false">http://infrequently.org/?p=1425</guid>
		<description><![CDATA[JavaScript is a lovable language. Real closures, first class functions, incredibly dynamic behavior&#8230;it&#8217;s a joy when you know it well. Less experienced JS programmers often feel as though they&#8217;re waltzing in a minefield, though. At many steps along the path to JS enlightenment everything feels like it&#8217;s breaking down around you. The lack of block [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript is a lovable language. Real closures, first class functions, incredibly dynamic behavior&#8230;it&#8217;s a joy when you know it well.</p>
<p>Less experienced JS programmers often feel as though they&#8217;re waltzing in a minefield, though. At many steps along the path to JS enlightenment everything feels like it&#8217;s breaking down around you. The lack of block lexical scope sends you on pointless errands, the various OO patterns give you fits as you try to do anything but what&#8217;s in the examples, and before you know it even the trusty &#8220;dot&#8221; operator starts looking suspect. What do you <em>mean</em> that <code>this</code> doesn&#8217;t point to the object I got the function from?</p>
<p>Repairs for some of the others are on the way in ES6 so I want to focus on the badly  botched situation regarding &#8220;promiscuous <code>this</code>&#8220;, in particular how ES5 has done us few favors and why we&#8217;re slated to continue the cavalcade of failure should parts of the language sprout auto-binding.</p>
<p>Here&#8217;s the problem in 5 lines:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  _counter<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
  inc<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>._counter<span style="color: #339933;">++;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
node.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>See the issue? <code>obj.inc</code> results in a reference to the <code>inc</code> method <em>without</em> any handle or reference to its original context (<code>obj</code>). This is asymmetric with the behavior we see when we directly call methods since in that case the dot operator populates the <code>ThisBinding</code> scope. We can see it clearly when we assign to intermediate variables:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> _counter <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// global &quot;_counter&quot;, we'll see why later</span>
<span style="color: #003366; font-weight: bold;">var</span> inc <span style="color: #339933;">=</span> obj.<span style="color: #660066;">inc</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 1</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2</span>
inc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 1</span></pre></div></div>

<p>Reams have been written on the topic, and ES5&#8242;s belated and weak answer is to directly transcribe what JS libraries have been doing by providing a <code>bind()</code> method that returns <em>a new function object</em> that carries the correct <code>ThisBinding</code>. Notably, you can&#8217;t un-bind a bound function object, nor can you treat a bound function as equal to its unbound ancestor. This, then, is just an API formalism around the pattern of using closures to carry the <code>ThisBinding</code> object around:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> bind <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> obj<span style="color: #009900;">&#91;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Event handling now looks like:</span>
<span style="color: #006600; font-style: italic;">//   node.addEventListener(&quot;click&quot;, bind(obj, &quot;inc&quot;));</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> inc <span style="color: #339933;">=</span> bind<span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;inc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 1</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2</span>
inc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 3</span>
&nbsp;
inc <span style="color: #339933;">===</span> obj.<span style="color: #660066;">inc</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span></pre></div></div>

<p>ES5&#8242;s syntax is little better but it is built-in and can potentially perform much better:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> inc <span style="color: #339933;">=</span> obj.<span style="color: #660066;">inc</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// In a handler:</span>
node.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> obj.<span style="color: #660066;">inc</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Syntax aside, we didn&#8217;t actually solve the big problems since unbound functions <em><b>can still exist</b></em>, meaning we still have to explain to developers that they need to think of the dot operator doing different things based on what charachters happen to come <em>after</em> the thing on the right-hand side of the dot. Worse, when you get a function it can either be strongly-bound (i.e., it breaks the <code>.call(otherThis, ...)</code> convention) or unbound &#8212; potentially executing in the &#8220;wrong&#8221; <code>ThisBinding</code>. And there&#8217;s no way to tell which is which.</p>
<p>So what would be better?</p>
<p>It occurs to me that what we need isn&#8217;t automatic binding for some methods, syntax for easier binding, or even automatic binding for all methods. No, what we really want is <em>weak binding</em>; the ability to retrieve a function object through the dot operator and have it do the right thing <em>until you say otherwise</em>.</p>
<p>We can think of weak binding as adding an annotation about the source object to a reference. Each de-reference via [[Get]] creates a new weak binding which is then used when a function is called. This has the side effect of describing current [[Get]] behavior when calling methods (since the de-reference would carry the binding and execution can be described separately). As a bonus, this gives us the re-bindability that JS seems to imply should be possible thanks to the <code>.call(otherThis)</code> contract:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> o <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  log<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  msg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;hello, world!&quot;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> o2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  msg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;howdy, pardner!&quot;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
o.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;hello, world!&quot;</span>
o2.<span style="color: #660066;">log</span> <span style="color: #339933;">=</span> o.<span style="color: #660066;">log</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// calling log through o2 replaces weak binding</span>
o2.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;howdy, pardner!&quot;</span></pre></div></div>

<p>But won&#8217;t this break the entire interwebs!?!?</p>
<p>Maybe not. Hear me out.</p>
<p>We&#8217;ve already seen our pathological case in earlier examples. Here&#8217;s the node listener use-case again, this time showing us exactly what context is being used for unbound methods:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">body</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span> <span style="color: #339933;">==</span> document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true in Chrome and FF today</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We can think of dispatch of the event calling the anonymous function with explicit <code>ThisBinding</code>, using something like <code>listener.call(document.body, evt);</code> as the call signature for each registered handler in the capture phase. Now, it&#8217;s pretty clear that this is whack. DOM dispatch changing the <code>ThisBinding</code> of passed listeners is an incredibly strange side-effect and means that even if we add weak binding, this context doesn&#8217;t change. At this point though we can clearly talk about the DOM API bug in the context of sane, consistent language behavior. The fact that event listeners won&#8217;t preserve weak binding and will continue to require something like this is an issue that can be wrestled down in <em>one</em> working group:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">node.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> 
       <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> ... <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>otherThis<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
       <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The only case I can think of when weak bindings will change program semantics is when unbound method calls in the global object do work on <code>this</code> in a way that is intentional. We have this contrived example from before too, but as you can see, it sure looks like a bug, no?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> _counter <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// a.k.a.: &quot;this._counter&quot;, a.k.a.: &quot;window._counter&quot;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  _counter<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
  inc<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>._counter<span style="color: #339933;">++;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> inc <span style="color: #339933;">=</span> obj.<span style="color: #660066;">inc</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 1</span>
obj.<span style="color: #660066;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>obj._counter<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>._counter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2, 0</span>
inc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 1</span>
inc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>obj._counter<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>._counter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2, 2</span></pre></td></tr></table></div>

<p>If this turns out to be a problem in real code, we can just hide weak bindings behind some <code>use</code> directive.</p>
<p>Weak binding now gives us a middle ground: functions that are passed to non-pathological callback systems &#8220;do the right thing&#8221;, most functions that would otherwise need to have been bound explicitly can Just Work (and can be rebound to boot), and the wonky [[Get]] vs. [[Call]] behavior of the dot operator is resolved in a tidy way. One less bit of unexploded ordinance removed.</p>
<p>So the question now is: why won&#8217;t this work? TC39 members, what&#8217;s to keep us from doing this in ES6?</p>
<p><b>Update:</b> Mark Miller flags what looks to be a critical flaw:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  callbacks<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  register<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>func<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> i <span style="color: #339933;">&lt;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">callbacks</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">callbacks</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">register</span><span style="color: #009900;">&#40;</span>foo.<span style="color: #660066;">bar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Does the wrong thing!</span></pre></div></div>

<p>The problem here is our call into each of the callback functions which still execute in the scope of the wrong object. This means that legacy code still does what it always did, but that&#8217;s just as broken as it was. We&#8217;d still need new syntax to make things safe. Ugg.</pre>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2010/09/javascript-uxo-removal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ending The ga.js Wait</title>
		<link>http://infrequently.org/2009/04/ending-the-gajs-wait/</link>
		<comments>http://infrequently.org/2009/04/ending-the-gajs-wait/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 04:10:16 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=908</guid>
		<description><![CDATA[Google Analytics is ubiquitous, not least of all because it&#8217;s better at what it does than most of the alternatives. Also, it doesn&#8217;t require any install or maintenance. And it&#8217;s free. What&#8217;s not to like? Frankly, not much, but if I had to nit pick, I&#8217;d note that the worst part of Google Analytics is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.google.com/analytics/">Google Analytics</a> is ubiquitous, not least of all because it&#8217;s better at what it does than most of the alternatives. Also, it doesn&#8217;t require any install or maintenance. And it&#8217;s free. What&#8217;s not to like?</p>
<p>Frankly, not much, but if I had to nit pick, I&#8217;d note that the worst part of Google Analytics is the <a href="http://www.google-analytics.com/ga.js"><code>ga.js</code></a> script that does the actual tracking of content. It&#8217;s not bad, in and of itself, but it tends to load slowly. There are several reasons for this:</p>
<ul>
<li><b>Another DNS lookup to resolve <code>http://www.google-analytics.com/</code></b>. This DNS entry is likely to be &#8220;warm&#8221; given how frequently <code>ga.js</code> is used on the web, but as <a href="http://blog.chromium.org/2008/09/dns-prefetching-or-pre-resolving.html">Jim Roskind explained on the Chromium blog</a>, it&#8217;s the outliers that kill you.</li>
<li><b>It&#8217;s kinda big</b>. At 9K on the wire (22K unzipped), <code>ga.js</code> is kinda chunky for what it does most of the time, namely tracking a single page load.</li>
<li><b>The <a href="http://code.google.com/apis/analytics/docs/tracking/gaTrackingOverview.html">default instructions</a> are bone-headed</b>. They direct you to do a <code>document.write()</code> which is a blocking, synchronous operation WRT page loading. This is tres <a href="http://raibledesigns.com/rd/entry/oscon_2008_even_faster_web">dumb</a>. Reasonable people should just include <code>ga.js</code> with a <code>&lt;script&gt;</code> tag, but nearly nobody does. Turns out that sane defaults still matter.</li>
<li><b>Load times seem totally random.</b> As with DNS lookup, <code>ga.js</code>&#8216;s latency varies wildly. This isn&#8217;t backed up by anything empirical, but many pages feel blocked by <code>ga.js</code> for a near eternity.</li>
</ul>
<p>So how to fix this? Dojo 1.3&#8242;s <code>dojox.analytics.Urchin</code> to the rescue!  Given that I was going to be including Dojo on the page to do other things anyway, I can use 1.3&#8242;s new Urchin system to help amortize the cost of using Google Analytics. The code running on this blog now includes the following code (more or less):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;
  src=&quot;http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js&quot;&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  dojo.addOnLoad(function(){
    setTimeout(function(){
      dojo.require(&quot;dojox.analytics.Urchin&quot;);
      dojo.addOnLoad(function(){
        var tracker = new dojox.analytics.Urchin({
          acct: &quot;UA-XXXXXX-X&quot; // your tracking # here
        });
      });
    }, 100);
  });
&lt;/script&gt;</pre></td></tr></table></div>

<p>You can see the real thing by looking at the bottom of this page which pulls in <a href="http://alex.dojotoolkit.org/wp-content/themes/sandbox/custom.js">custom.js</a> which includes this logic. <a href="http://higginsforpresident.net/2008/06/google-analytics-after-onload/">Pete Higgins blogged about how the module works when he first wrote it</a>, and the strategy is to load Dojo from a CDN (since the page wanted it for other things) and wait until after the page has loaded to include <code>ga.js</code>. This delayed loading ensures that the page is responsive before we start doing anything related to tracking. The nested calls to <code>dojo.addOnLoad</code> show how we can wait for one set of modules to finish before kicking off another group, and in this case we also wait until after the page is responsive to load <code>dojox.analytics.Urchin</code>. This module further delays loading of <code>ga.js</code>, meaning that it doesn&#8217;t matter how long it takes for things like DNS to resolve and for Google to serve <code>ga.ja</code> since it&#8217;s not ever blocking the user.</p>
<p>Looking at the &#8220;before&#8221; and &#8220;after&#8221; shots in firebug gives you some idea of how this technique can really make a difference:</p>
<div style="padding-left: 50px; font-style: italic;">
<div id="attachment_940" class="wp-caption aligncenter" style="width: 310px"><a href="http://alex.dojotoolkit.org/wp-content/uploads/2009/04/before_loading_detail.png"><img src="http://alex.dojotoolkit.org/wp-content/uploads/2009/04/before_loading_detail-300x103.png" alt="onload waits for ga.js" title="before_loading_detail" width="300" height="103" class="size-medium wp-image-940" /></a><p class="wp-caption-text">onload waits for ga.js</p></div></p>
<p><div id="attachment_941" class="wp-caption aligncenter" style="width: 310px"><a href="http://alex.dojotoolkit.org/wp-content/uploads/2009/04/loading_detail.png"><img src="http://alex.dojotoolkit.org/wp-content/uploads/2009/04/loading_detail-300x102.png" alt="using dojox.analytics.Urchin, we can get a responsive page and *then* track usage" title="loading_detail" width="300" height="102" class="size-medium wp-image-941" /></a><p class="wp-caption-text">using dojox.analytics.Urchin, we can get a responsive page and *then* track usage</p></div>
</div>
<p>We get page tracking and the user gets an interactive page faster. Rad.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2009/04/ending-the-gajs-wait/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Census 2: More Than Just A Pretty Graph</title>
		<link>http://infrequently.org/2008/12/census-2-more-than-just-a-pretty-graph/</link>
		<comments>http://infrequently.org/2008/12/census-2-more-than-just-a-pretty-graph/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 15:59:07 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[dhtml]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[benchmarks]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=849</guid>
		<description><![CDATA[Numbers without context are lies waiting to be repeated.]]></description>
			<content:encoded><![CDATA[<p>Benchmarks are hard, particularly for complex systems. As a result, the most hotly contested benchmarks tend not to be representative of what makes systems faster for real users. Does another 10% on <a href="http://www.tpc.org/default.asp">TPC</a> really matter to most web developers? And should we really pay any attention to how <em>any</em> JS VM does on <a href="http://shootout.alioth.debian.org/">synthetic language benchmarks</a>?</p>
<p>Maybe.</p>
<p>These things matter only in regards to how well they represent end-user workloads and how trustworthy their findings are. The first is much harder than the second, and end-to-end benchmarking is pretty much the only way to get there. As a result, sites like <a href="http://www.tomshardware.com/">Tom&#8217;s Hardware</a> focus on application-level benchmarks while still publishing &#8220;low level&#8221; numbers. Venerable test suites like <a href="http://en.wikipedia.org/wiki/SPECint">SPECint</a> have even moved toward running &#8220;full stack&#8221; style benchmarks which may emphasize a particular workload but are broad enough to capture the wider system effects which matter in the real world.</p>
<p>Marketing departments also like small, easily digestible, whole numbers. Saying something like &#8220;200% Faster!&#8221; sure sounds a lot better than &#8220;on a particular test which is part of a larger suite of tests, our system ran in X time vs. Y time for the competitor&#8221;. Both may be true, but the second statement gives you some context. Preferably even that statement would occur above an actual table of numbers or graphs. Numbers without context are lies waiting to be repeated.</p>
<p>With all of this said, <a href="http://www.jamesward.com/blog/">James Ward&#8217;s</a> <a href="http://jamesward.com/census">Census</a> benchmark makes a valiant stab at a full-stack test of data loading and rendering performance for RIA technologies. Last month <a href="http://dojotoolkit.org/2008/11/05/flash-flex-versus-open-web-ajax">Jared</a> dug further into the numbers and found the methodology wanting, but given some IP issues couldn&#8217;t patch the sources himself. Since I wasn&#8217;t encumbered in the same way I thought I might as well try my hand at it, but after hours of attempting to get the <a href="http://sourceforge.net/projects/flexapps">sources to build</a>, I finally gave up and decided to re-write the tests. The result is <a href="http://textterm.com/census.html">Census 2</a>.</p>
<p><a href="http://textterm.com/census.html"><img src="http://alex.dojotoolkit.org/wp-content/uploads/2008/12/census2_main_small.png" style="border: 0px;"/></a></p>
<p>There are several goals of this re-write:</p>
<ul>
<li><b>Fairness.</b> Tests need to be run multiple times for them to be representative in any way. Likewise, systems not being directly tested need to be factored out as much as possible. C2 does this by reducing the number of dependencies and running tests (at least) 5 times and discarding outliers before reporting an average. I&#8217;ve also worked to make sure that the tests put the best foot forward for all of the tested technologies.</li>
<li><b>Hackability.</b> Benchmarks like Census serve first as a way for decision makers to understand options but second as a way for developers to know how they&#8217;re doing. Making it trivial to add tests helps both audiences.</li>
<li><b>Portability.</b> The test suite should run nearly everywhere with a minimum of setup and fuss. This ensures that the largest numbers of people can benefit from the fairness and hackability of the tests.</li>
</ul>
<p>The results so far have been instructive. On smaller data sets HTML wins hands-down for time-to-render, even despite its disadvantage in over-the-wire size. For massive data sets, pagination saves even the most feature-packed of RIA Grids, allowing the Dojo Grid to best even XSLT and a more compact JSON syntax. Of similar interest is the delta between page cycle times on modern browsers vs their predecessors. Flex can have a relatively even performance curve over host browsers, but the difference between browsers today is simply stunning.</p>
<p>Given the lack of an out-of-the-box paginating data store for Flex, RIAs built on that stack seem beholden to either Adobe&#8217;s <a href="http://www.adobe.com/products/livecycle/dataservices/">LCDS licensing</a> or are left to build ad-hoc pagination into apps by hand to get reasonable performance for data-rich business applications. James Ward has already exchanged some mail with me on this topic and it&#8217;s my hope that we can show how to do pagination in Flex without needing LCDS in the near future. </p>
<p>The tests aren&#8217;t complete. There&#8217;s still work to do to get some of the SOAP and AMF tests working again. If you have ideas about how to get this done w/o introducing a gigantic harball of a Java toolchain, I&#8217;m all ears. Also on the TODO list is an <a href="http://code.google.com/appengine/">AppEngine app</a> for recording and analyzing test runs so that we can say something interesting about performance on various browsers. </p>
<p>Census 2 is very much <a href="http://code.google.com/p/census2/">an open source project</a> and so if you&#8217;d like to get your library or technology tested, please don&#8217;t hesitate to send me mail or, better yet, attach patches to the <a href="http://code.google.com/p/census2/issues/list">Bug Tracker</a>.</p>
<p><b>Update:</b> I failed to mention earlier that one of the largest changes in C2 vs. Census is that we report <em>full page cycle times</em>. Instead of reporting just the &#8220;internal&#8221; timings of an RIA which has been fully boostrapped, the full page times report the full time from page loading to when the output is responsive to user action. This keeps JavaScript frameworks (or even Flex) from omitting from the reports the price that users pay to download their (often sizable) infrastructure. There&#8217;s more work to do in reporting overall sizes and times (&#8220;bandwidth&#8221; numbers don&#8217;t report gzipped sizes, e.g.), but if you want the skinny on real performance, scroll down to the red bars. That&#8217;s where the action is.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/12/census-2-more-than-just-a-pretty-graph/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Why Are We Even Having This Discussion?</title>
		<link>http://infrequently.org/2008/10/why-are-we-even-having-this-discussion/</link>
		<comments>http://infrequently.org/2008/10/why-are-we-even-having-this-discussion/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 21:47:43 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[blog chatter]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[acorn]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[rights]]></category>
		<category><![CDATA[voting]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=807</guid>
		<description><![CDATA[Content after the jump due to the public policy nature of the post. Here we go again. Every four years we go into the partisan spasms of a heat-not-light [dis]enfranchisement &#8220;debate&#8221;. What&#8217;s perpetually lost is any coherent discussion of the causes of the debate. As with gerrymandering, the causes are structural and neither party feels [...]]]></description>
			<content:encoded><![CDATA[<p>Content after the jump due to the public policy nature of the post.</p>
<p><span id="more-807"></span></p>
<p><a href="http://www.nytimes.com/2008/10/17/opinion/17fri1.html?_r=1&#038;ref=opinion&#038;oref=slogin">Here we go again.</a></p>
<p>Every four years we go into the partisan spasms of a heat-not-light [dis]enfranchisement &#8220;debate&#8221;. What&#8217;s perpetually lost is any coherent discussion of the causes of the debate. As with <a href="http://en.wikipedia.org/wiki/Gerrymandering">gerrymandering</a>, the causes are structural and neither party feels it would serve them to effectively deal with the situation at it&#8217;s roots. Not because solving the problem wouldn&#8217;t be better for everyone (in both cases, it objectively would), but because <em>it would change the game, and our 2-party system is nothing if not over-specialized to the current rules of the game</em>. In this sense, both redistricting reform (killing gerrymandering dead) and automatic voter registration systems cause the old rules to lose their hold, instantly changing the calculus of holding on to power. Automatic registration via so-called &#8220;motor-voter&#8221; laws, registration with passport applications, automatic updates with change-of-address on US mail, and other sensible policies are opposed by partisans of <em>both</em> parties because they have the potential to allow discontent to cause large swings in electorate behavior. Today, between the systematic disenfranchisement caused by requiring citizens to register to vote and the effective gerrymandering-based dampening of popular will, <em>enormous</em> changes in <em>likely voter</em> feelings about the direction of the country (or, less often, a locality/district) are required to break an incumbent&#8217;s grip on power. As an example, the <a href="http://www.pollingreport.com/right.htm">&#8220;right-track/wrong-track&#8221; polling numbers</a> in 2006 said that nearly 70% of Americans thought the country was on the wrong track. That feeling swept the Democrats into a razor-thin congressional majority (which the Republicans have been filibustering to death ever since), but in a 2:1 year, wouldn&#8217;t you expect a similar landslide in Congress? Perhaps not in the Senate where fewer seats are up for a vote as a structural hedge against change, but certainly we should have collectively turned enough of the bums out to make the remaining ones fear for their jobs. As it happened, in a race with 33 seats up for discussion (15 held by Republicans), <em><a href="http://en.wikipedia.org/wiki/United_States_Senate_elections,_2006">only 5 of the bums lost their seats</a></em>. Now compare that to the most recent pre-Bush period of comparable &#8220;right-track/wrong-track&#8221; numbers: the Republican revolution&#8221; of &#8217;94. <a href="http://en.wikipedia.org/wiki/United_States_Senate_elections,_1994">On that basis it becomes evident that a shift in power half-again as large &ndash; based on the same &#8220;market fundamentals&#8221; &ndash; was <em>at least</em> justified</a>. 8 seats changed hands in &#8217;94 vs. 5 in &#8217;06. The difference? A census and therefore a chance for many states to gerry&#8230;.er&#8230;redistrict. The calcifying power of&#8230;um&#8230;power worked its magic 2 years ago and the Senate is deadlocked as a result.</p>
<p>All of these effects cause fewer parts of the country to be competitive. If you support competition in markets (as I do), then there&#8217;s no higher calling than supporting a competitive marketplace for ideas, and both parties are doing their best to stifle the pricing function of our public policy market. No wonder then that Republicans think they can steal (or at least dispute) an election by challenging voters in Ohio, despite <a href="http://www.talkingpointsmemo.com/archives/237825.php">many discredited attempts in the past to find large-scale vote fraud</a>. Eight years of intense Republican scrutiny into the non-issue has utterly failed to turn up any massive conspiracy or even credible small-scale fraud. Remember, pressuring US AG&#8217;s to prosecute thin or non-existent voter fraud cases &ndash; then firing them when they couldn&#8217;t find any and/or wouldn&#8217;t make them up &ndash; is what got Alberto Gonzalez hauled before congress for months on end, eventually leading to his disgraced resignation and continuing questions as to the impartiality of the DOJ. This isn&#8217;t a winner of an issue for the GOP, but it sure is an effective way to try to keep the under-informed from coming to the polls and having their votes counted. And they know it. Scare-tactics and fear-mongering as [keep|get]-out-the-vote strategy. Democrats, naturally, feel that their on-the-ground vote registration in targeted areas can be an effective weapon in distorting the outcome.</p>
<p>Either way, it&#8217;s shameful.</p>
<p>The Democratic approach is perhaps less reprehensible since the folks who are registered can vote however they please, but there&#8217;s no denying the attempt at demographic distortion. But why should citizens need to register as a separate process from establishing residency, getting mail, or a driver&#8217;s license anyway? And why isn&#8217;t <a href="http://en.wikipedia.org/wiki/Election_Day_Registration">same-day registration</a> the law of the land? If Wyoming can do it, why not New York and California? </p>
<p>Fundamentally, all the objections to broad enfranchisement end in a large-scale IT problem&#8230;but not a particularly hard one. What I&#8217;m not hearing from nearly anyone is a recognition that this shouldn&#8217;t be a debate that happens in a functioning democracy. That we have it on a quadrennial basis is simply an embarrassing acknowledgment that our democracy is <em>not</em> functioning.</p>
<p>If McCain really wants to put &#8220;country first&#8221; and be a maverick, he&#8217;d be bringing this up as an urgent topic of national debate. It would certainly be better than the sleazy <a href="http://tpmelectioncentral.talkingpointsmemo.com/2008/10/did_mccain_hire_same_firm_to_d.php">robo-call effort</a> his campaign is now investing in. And if Obama wanted to build real credibility with Americans about his willingness to effect real change, shouldn&#8217;t he start here? Certainly it&#8217;s a better use of the national discourse than <a href="http://www.nytimes.com/2008/10/17/us/politics/17webplumber.html?ref=politics">helping McCain draw unwarranted (and likely un-wanted) attention to a plumber.</a> And where the hell is the 4th Estate when we need them?</p>
<p>Oh, right. Camped out on some plumber&#8217;s lawn.</p>
<p>Luckily, I happen to live in California where the Governor (who I disagree with more than not) <a href="http://www.voterguide.sos.ca.gov/title-sum/prop11-title-sum.htm">has put redistricting reform on the ballot in the form of Prop. 11</a>. I&#8217;ll be voting &#8220;yes&#8221; on 11, if only to make it that less likely that 4 years from now we&#8217;ll have to have this &#8220;discussion&#8221; again.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/10/why-are-we-even-having-this-discussion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Action Oriented Programming&#8221;</title>
		<link>http://infrequently.org/2008/10/action-oriented-programming/</link>
		<comments>http://infrequently.org/2008/10/action-oriented-programming/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 16:40:13 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[closures]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=783</guid>
		<description><![CDATA[It&#8217;s good to be back in SF after a pretty hectic week in Boston for Dojo Developer Days and The Ajax Experience. There&#8217;s a lot to say about them, which hopefully I&#8217;ll get to in a longer post. Our first DDD event under Pete&#8216;s excellent leadership was a success and Dojo and SitePen very well [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s good to be back in SF after a pretty hectic week in Boston for Dojo Developer Days and The Ajax Experience. There&#8217;s a lot to say about them, which hopefully I&#8217;ll get to in a longer post. Our first DDD event under <a href="http://higginsforpresident.net/">Pete</a>&#8216;s excellent leadership was a success and Dojo and SitePen very well represented at the conference.</p>
<p>While in Boston, <a href="http://blog.xdraw.org/">Gavin</a> and <a href="http://www.eyelevelpasadena.com/">Jill</a>  joined a gaggle of Dojo hackers at a dinner ostensibly to mourn my birthday (thanks to Dylan and Pete for organizing!) and in the course of conversation Jill asked something along the lines of:</p>
<blockquote><p>
So why do people get so excited about closures?
</p></blockquote>
<p>Which prompted a several of us to flail and flop gasping the salt flats of analogy like fish out of polite-conversation water. After about 10 minutes of this, Jill succinctly summed it all up in the form of a question:</p>
<blockquote><p>
Oh, so it&#8217;s like &#8220;action-oriented programming&#8221;?
</p></blockquote>
<p>This is perhaps the most insightful and succinct description I have ever heard of what JavaScript is all about.</p>
<p><b>Update:</b> <a href="http://tharpo.com">Jennifer</a> just played <a href="http://blogs.wnyc.org/radiolab/2008/07/29/tell-me-a-story/">this for me</a> and it gets right to the heart of this post: the important part of doing what we do with computers, and more importantly, with the web, is to give the power of Computer Science to real people&#8230;and it starts with insights like Jill&#8217;s that build a shared way of thinking and talking about the world. It makes me sad that many programmers miss that, but when non-programmers can share in the beauty and power of code, it does a lot to make it all seem worthwhile.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/10/action-oriented-programming/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Importance Of Chrome</title>
		<link>http://infrequently.org/2008/09/the-importance-of-chrome/</link>
		<comments>http://infrequently.org/2008/09/the-importance-of-chrome/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:28:44 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[dhtml]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[openweb]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[strategy]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=747</guid>
		<description><![CDATA[The rumors seem to have been true&#8230;the gBrowser is real. And it looks like it will simply be awesome. To my friends who have been toiling on it in deep secrecy for so very long, congratulations. Yes, yes, more to do, blah blah&#8230;screw that. You shipped! Huzzah! So what does Chrome mean for those of [...]]]></description>
			<content:encoded><![CDATA[<p>The rumors seem to have been true&#8230;<a href="http://googleblog.blogspot.com/2008/09/fresh-take-on-browser.html">the gBrowser is real</a>. And it looks like it will simply be awesome. To my friends who have been toiling on it in deep secrecy for so very long, congratulations. Yes, yes, more to do, blah blah&#8230;screw that. You shipped! Huzzah!</p>
<p>So what does Chrome mean for those of us who aren&#8217;t breaking out the champagne? Well, first, it&#8217;s the second sign (after <a href="http://gears.google.com/">Gears</a> and YBP (<a href="http://alex.dojotoolkit.org/2008/06/gears-de-brands-2/">har!</a>)) that the content authors are taking back the web from the &#8220;browser guys&#8221;. I&#8217;ve been fascinated for the last 6 months or so by the strategic mis-alignment which results when both the browsing and authoring experience in the hands of organizations only care about one but not the other. Mozilla gets paid by search-box revenue and users download it because it&#8217;s better for browsing, therefore Mozilla is incented to <a href="http://www.adaptivepath.com/aurora/">build new ways to browse</a>, but their investments in content are somewhat mis-aligned (and, frankly, <a href="http://labs.mozilla.com/">it shows</a>). Google and Yahoo, on the other hand, are critically dependent on the content getting better, so they produce plugins to augment HTML in un-intrusive ways. Chrome crosses over into the browser business <em>from the perspective of content</em>, and it also shows, albeit in a good-ish way. I guess we&#8217;ll need to wait and see how browsing-oriented Chrome gets (e.g., will it sprout an extensions platform &ndash; ala Firefox &ndash; or will the propsect of an ad-blocking plugin for the Google browser make that proposal D.O.A.?).</p>
<p>Regardless of how Chrome evolves as a product, the important question now is: how will it be distributed? The obviously non-evil thing to do is to say &#8220;look, it&#8217;s great, it&#8217;s free&#8221; and hope that the world discovers it on its own thanks to word-of-mouth and/or leverage of the Google brand. Given that Chrome delivers new awesome things which are end-user-visible (some &#8220;end-user-awesome&#8221;, if you will), there&#8217;s some real chance that Chrome can get to roughly Firefox level market-share without breaking too much of a sweat. Not that Firefox&#8217;s market share is anything to really covet, given that MoFo/MoCo have been toiling at it for a decade now. To get real, honest-to-god leverage out of this process, Chrome is going to need something like 60+% market share, and that means changing ingrained user habits. I put the probability of that happening without distribution channel love at roughly bupkis.</p>
<p>Microsoft killed Netscape by bundling the browser with the OS. Apple is <a href="http://marketshare.hitslink.com/report.aspx?sample=15&#038;qprid=22&#038;qpdt=1&#038;qpct=5&#038;qptimeframe=M&#038;qpsp=101&#038;qpnp=12&#038;qprid2=3&#038;qpcustom2=Firefox+3.0">making inroads by bundling</a>. Firefox is even <a href="http://marketshare.hitslink.com/report.aspx?sample=15&#038;qprid=22&#038;qpdt=1&#038;qpct=5&#038;qptimeframe=M&#038;qpsp=101&#038;qpnp=12&#038;qprid2=3&#038;qpcustom2=Firefox+3.0#">getting aggressive</a>. So where does this leave &#8220;don&#8217;t be evil&#8221;? Given the <a href="http://weblogs.java.net/blog/kgh/archive/2005/10/java_se_and_the.html">toolbar promotional deals</a> which Google has cut in the past, I think there&#8217;s some organizational capacity inside the Goog to use the distribution channels they&#8217;ve already created as a way of getting to critical mass. What I don&#8217;t see, though, is a view of how to bring the mission of Gears into alignment with Chrome (or vice versa). They&#8217;re both important, but Chrome is a long-term bet while Gears is the near-future solution. They are not in opposition, but their strategies for gaining leverage over the problems facing content authors are very different.</p>
<p>We need what Gears can offer to every browser <em>right now</em> while Chrome dukes it out for market share on the browsing experience merits. Hopefully, if nothing else, the Chrome installer will add Gears to other browsers on the system that users install Chrome to. Even if they don&#8217;t pick the googly experience for browsing day-to-day, perhaps Chrome can still serve to give new tools to the content-author side of the house. Other browser vendors won&#8217;t do such a thing since they win or loose on an exclusive &#8220;I must replace the other guy&#8221; basis. Here, Google (and by &#8220;Google&#8221;, I mean &#8220;the open web&#8221;) wins either way. Hopefully Google&#8217;s interest in making the content experience better trumps the &#8220;we&#8217;re all browser guys now&#8221; instinct in this case.</p>
<p>We&#8217;ll find out tomorrow, I guess. Here&#8217;s to hoping.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/09/the-importance-of-chrome/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Harmony Fallout</title>
		<link>http://infrequently.org/2008/08/harmony-fallout/</link>
		<comments>http://infrequently.org/2008/08/harmony-fallout/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 08:33:17 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[openweb]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=731</guid>
		<description><![CDATA[Lets end the silly meme that "Adobe lost" or that "Microsoft won". The game has hardly begun and it won't be settled in a standards body anyway. ]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a lot of weirdness going on around the Harmony announcement. <a href="http://whydoeseverythingsuck.com/2008/08/ru-roh-adobe-screwed-by-ecmascript.html">This post in particular</a> tries to dig into some of the wrangling that caused the ES4/3.1 split and what the Oslo resolution &#8220;means&#8221;, but I&#8217;m afraid that much of the analysis is being done without the benefit of an inside view of the WG process.</p>
<p>At the risk of talking too much out of school, I want to set the record straight in some ways. First, let me set some facts out:</p>
<ul>
<li>ES4, <a href="http://www.ecmascript.org/es4/spec/overview.pdf">as outlined last fall</a>, was <b>not</b> ActionScript 3. <em>Major</em> changes to the semantics of Adobe&#8217;s initial contribution ensured that any truly compliant ES4 implementation from Adobe would have required many concessions, including the inclusion of a client-side compiler. ES4 without <code>eval()</code> (ala AS3) would never have cut it as a &#8220;real&#8221; ES4.</li>
<li>Adobe had not donated &#8220;ActionScript 3&#8243; to Mozilla nor Open Sourced ActionScript 3. Adobe had donated a high-performance byte-code VM which a separate front-end compiler targeted. It is absolutely possible that the Tamarin VM can and will run <em>whatever</em> syntax for the next version of JavaScript is ratified. The design of the VM is, of course, predicated upon the language semantics but lets not confuse the front-end compiler and the language that it consumes with the VM and byte-code format which it executes. The front-end compiler was not donated to Mozilla (although something similar exists in the OSS&#8217;d Flex SDK) nor does it ship inside of the Flash player today. Adobe can continue to evolve their developer languages and byte-code VMs independently so long as they never ship an <code>eval()</code> feature. Even if they do, there are other (harder to swallow) options available, but no road is cut off to Adobe which was not already long-since abandoned in other ways by the ES4 process.</li>
<li>Like Adobe, Microsoft has jumped ahead in the evolution of JavaScript via the seemingly forgotten JScript.NET. Like Adobe, Microsoft has had to come back from that position to meet the web where it really is. Microsoft now ships 3 &ndash; yes, that&#8217;s right, <em>three</em> &ndash; JavaScript-ish languages which are capable of running in a browser:
<ul>
<li>JScript (via Windows Scripting Host)</li>
<li>JScript.NET</li>
<li>JScript for the DLR (via Silverlight)</li>
</ul>
<p>Make no mistake about it, these are all separate implementations which likely share little if any code. The DLR variant is even new in the last several years. Creating a new JavaScript compiler and runtime is not an overly onerous task for MSFT and clearly not one that will take a long time should the occasion arise. What&#8217;s confusing and can likely be tied to strategic wrangling is the puzzling lack of progress in the WSH version of JScript (the one everyone uses day-to-day). Any strategic discussion of JScript as a platform needs to start from this perspective.</li>
<li>Much in ES4 was new. The gradual typing system (which I&#8217;m a big supporter of) was something of a large-scale experiment coupled with as much rigor as I&#8217;ve ever seen in a standards body in proving things out in an RI. The Class system (which I wasn&#8217;t a big supporter of) needed to marry class-based inheritance to prototypal inheritance in ways which were new. ES4 contained many good features and syntactic forms which were borrowed from other places, but as Brendan Eich has said, it was a process of synthesis plus invention. In my opinion, much of the failure of ES4 as an initiative can be traced to significant failings of ActionScript 3 <em>as a language</em>. AS3 is a Java-like language with a Java-like execution model. JavaScript is a dynamic language with a dynamic execution model. The gulf in expectations between those camps turns up in every corner of the language design. For instance: what does it mean to load new code? Are classes forever &#8220;closed&#8221; or can they be re-opened? Do you <em>really</em> need the <code>static</code> and <code>final</code> keywords? Solving these issues in the context of the old is easy. In the context of the new, it&#8217;s hard. ES4 suffered because it had to do it in a new world which no one was yet writing code for.</li>
</ul>
<p>So, lets pop up and talk about strategy for a minute. Fundamentally, very little has changed in terms of available strategic options for any of the players:</p>
<ul>
<li>MSFT can still hold the web hostage to their ailing WSH VM by continuing to ignore its performance, regardless of bug fixes and syntactic updates. Doesn&#8217;t matter if it&#8217;s amputation or debilitating arthritis, crippled is crippled. For what it&#8217;s worth, my interactions with the MSFT reps on TC39 give me no reason to believe that they won&#8217;t be improving their VM.</li>
<li>Adobe can still chose to implement a language which implements an ECMA spec. They can do this any time they damn-well please. It may not align so cleanly with their current technology roadmap, but it&#8217;s absolutely feasible and when Mozilla ships a &#8220;regular JavaScript&#8221; front-end to the Tamarin back-end, it&#8217;ll be even easier. Note that this plan can be done in parallel with AS3 evolution since Tamarin (as a VM) need not be aware of any language semantics on its own.</li>
<li>Browser vendors can still wring large speedups out of ES3 and 3.1</li>
</ul>
<p>What died here wasn&#8217;t Adobe&#8217;s attempts to &#8220;own&#8221; a spec. If there were such hopes in play, they had been quietly put down one rational, backwards compatible decision after another in the year preceding the Oslo meeting. What died was an assumption that the web can evolve without implementations being out in front of the spec. AS3 was one implementation of a JavaScript-like language that might have been a contender for crown of &#8220;the next one&#8221;, but so was JScript.NET. That neither of them &#8220;won&#8221; simply because they had been built in good faith is as true a sign as I can find that the process is working. <a href="http://blogs.adobe.com/open/2008/08/blog_entry_dated_81408_715_pm.html">Adobe gets it</a>. Lets end the silly meme that &#8220;Adobe lost&#8221; or that &#8220;Microsoft won&#8221;. The game has hardly begun and it won&#8217;t be settled in a standards body anyway. What matters &ndash; and what we all need to keep our eyes keenly trained on &ndash; is what the big implementations do in the way of compatibility, performance, and feature set once ES3.1 arrives.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/08/harmony-fallout/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Transition</title>
		<link>http://infrequently.org/2008/08/transition/</link>
		<comments>http://infrequently.org/2008/08/transition/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 21:29:21 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[Dojo Foundaton]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=713</guid>
		<description><![CDATA[Two days ago I dusted off the rarely-used voting procedure for Dojo Foundation projects in order to kick off a transition that I&#8217;m very excited about: as of this afternoon, the committers of the Dojo project have elected Peter Higgins the new Project Lead for the toolkit project. I&#8217;ve had the pleasure of working with [...]]]></description>
			<content:encoded><![CDATA[<p>Two days ago I <a href="http://turtle.dojotoolkit.org/pipermail/dojo-contributors/2008-August/009571.html">dusted off the rarely-used voting procedure</a> for Dojo Foundation projects in order to kick off a transition that I&#8217;m very excited about: as of this afternoon, the committers of the Dojo project have <a href="http://turtle.dojotoolkit.org/pipermail/dojo-contributors/2008-August/009596.html">elected</a> <a href="http://higginsforpresident.net/">Peter Higgins</a> the new Project Lead for the toolkit project.</p>
<p>I&#8217;ve had the pleasure of working with Peter both in the Dojo project and at <a href="https://www.sitepen.com/">SitePen</a> and his energy and enthusiasm for making Dojo better and helping designers and developers work better together is infectious. </p>
<p>For anyone not familiar with Peter&#8217;s work, he&#8217;s been instrumental in the creation of the amazing <a href="http://dojocampus.org/">Dojo Campus</a> website (along with the <a href="http://blog.uxebu.com/">Uxebu chaps</a>) as well as being primary author of many DojoX components. His work in shepherding new contributors through the contributor to committer process is nearly legendary inside the project, and Peter has been a one-man outreach and support machine via the <a href="http://dojotoolkit.org/blog">Dojo blog</a> and his endless patience on the <a href="http://dojotoolkit.org/forum">forums</a> and IRC (#dojo on irc.freenode.net). I couldn&#8217;t be happier about where Dojo is headed under his direction.</p>
<p>There have already been some recurring questions about this transition amongst the committers and <a href="http://ajaxian.com/archives/open-web-podcast-episode-1-html-5-news-web-workers-w3c-selectors-and-dojo-happenings">on today&#8217;s Open Web podcast</a>, so let me quickly recap them here:</p>
<h3>Q: Will you still be involved in Dojo?</h3>
<p>Absolutely! I&#8217;m excited that Pete is taking on the figurehead and &#8220;vision thing&#8221; duties which is a role that he&#8217;s naturally suited to. Part of this transition is about me wanting more time to focus on experimental and edgy stuff that can make a huge difference in how we work with the web and I have no doubt that Peter is the right guy to help us grow the truly open Dojo community even further. He absolutely gets the importance of a truly open community, the need to be conservative about where IP comes from and meet our promises of backwards-compatibility, and how Dojo can make big changes in the lives of application developers and designers. I&#8217;m grateful to be have the opportunity to continue working with him on Dojo and will continue to do so in whatever capacity Peter deems appropriate.</p>
<h3>Q: Does this change your role at the Foundation?</h3>
<p>Nope. I&#8217;m still serving as President of the Dojo Foundation. This transition will allow me to also focus more time on ensuring that the Foundation is running well, that a new Board is elected soon, and that the Foundation&#8217;s other projects succeed on their own terms. The Foundation has always been about more than just giving Dojo a home, and we&#8217;re now looking to expand the umbrella of the Foundation to help nurture other JavaScript and Open Web projects more than ever.</p>
<h3>Q: Will you still be doing talks on Dojo?</h3>
<p>Yep, I&#8217;ll still be out there advocating the Dojo case, but you can expect to see Peter doing more of that over time as well. If you&#8217;re planning a conference and are looking for a cogent person to talk about Dojo, Peter is now your go-to guy. I&#8217;ve enjoyed having the opportunity to think and <a href="http://alex.dojotoolkit.org/?p=675">talk about where the Open Web is headed</a>, so I&#8217;ll also be doing a lot more of that. There are lots of meta-issues that this transition will let me work harder on, so expect more from me there.</p>
<p>My hat&#8217;s off to the Dojo community and Peter in particular. The work that has gone into 1.2 and will land in 1.3 and beyond under his direction really is changing the way we view what the web can and should be used for.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/08/transition/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>OSCON &#8217;08</title>
		<link>http://infrequently.org/2008/07/oscon-08/</link>
		<comments>http://infrequently.org/2008/07/oscon-08/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 01:31:39 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[licensing]]></category>
		<category><![CDATA[openweb]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=693</guid>
		<description><![CDATA[I&#8217;m leaving tomorrow for my yearly trek to Portland for OSCON. If you&#8217;re going, don&#8217;t hesitate to drop me a line if you want to catch up or RSVP for the Dojo meetup/dinner on Wed evening. Speaking as a member of the OSCON program committee, I&#8217;m very happy about the quality of the talks in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m leaving tomorrow for my yearly trek to Portland for <a href="http://en.oreilly.com/oscon2008/public/content/home">OSCON</a>. If you&#8217;re going, don&#8217;t hesitate to drop me a line if you want to catch up or <a href="http://dojotoolkit.org/2008/07/17/ddd-4-5-portland-oregon">RSVP for the Dojo meetup/dinner on Wed evening</a>.</p>
<p>Speaking as a member of the OSCON program committee, I&#8217;m <em>very</em> happy about the quality of the talks in the web-ish tracks this year. There&#8217;s even a Dojo talk &ndash; even though for the first time in a long while, I won&#8217;t be giving any talks. The <a href="http://en.oreilly.com/oscon2008/public/schedule/speaker/6606">inimitable Matthew Russell</a>, author of ORA&#8217;s <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FDojo-Definitive-Guide-Matthew-Russell%2Fdp%2F0596516487%2F&#038;tag=oreonbl-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Dojo: TDG</a> will be giving an awesome talk on 2D drawing with Dojo&#8217;s GFX system. I know he&#8217;s got some awesome demos worked up, so I can&#8217;t wait to see the talk. <a href="http://en.oreilly.com/oscon2008/public/schedule/speaker/6580">Gavin Doughtie</a>, occasional contributor to the GFX system, is also giving several talks that you&#8217;ll find me in. Should be a lot of fun.</p>
<p>On a more macro scale, though, I&#8217;ve started to become concerned that &#8220;Open Source&#8221; as a brand has lost its way. Those <a href="http://opensource.org/">who would speak for Open Source</a> have focused narrowly on licensing and have largely ignored the other social processes and artifacts that define what it means to contribute to OSS projects and how those artifacts lead to success or failure of projects, and therefore, of the movement such as it is. There&#8217;s a huge disconnect between what the letter of the Open Source law dictates (the licenses) and the social and process constraints that are required to build high-quality, trustable communities that ensure <a href="http://almaer.com/blog/being-open-is-hard-as-we-have-seen-this-week">100 point</a> OSS products, and many businesses have struck on these differences as a way to use the Open Source brand to imply or insinuate that users should trust their products more than is warranted. OSI&#8217;s failure to address this brand erosion has had some troubling effects in the small JavaScript corner of the OSS world of late, and I know we&#8217;re not alone. OSI has also proven completely impotent in preventing license proliferation, further eroding the Open Source brand. There are, of course, lots of folks who are also concerned about these thing, and so I&#8217;m excited to see <a href="http://en.oreilly.com/oscon2008/public/schedule/detail/4876">David Recordon</a> (of OpenID, etc. fame) giving a talk which looks to talk about some of the community aspects. I tend to blow off &#8220;community&#8221; talks at conferences, but given David&#8217;s use of the phrase &#8220;Open Web&#8221; and his unique perspective, I&#8217;ll be interested to see what he says. I&#8217;ll also be curious to see if and how any of this is discussed at the FLOSSCON meeting of OSS Foundation leaders tomorrow and Sunday.</p>
<p>If you&#8217;ll be in Portland next week, don&#8217;t hesitate to join us for the <code>dojo.dinner()</code> on Wed. I&#8217;m looking forward to seeing everyone again and talking though the issues. Should be a great time.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/07/oscon-08/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uxebu Hangs Their Shingle</title>
		<link>http://infrequently.org/2008/07/uxebu-hangs-their-shingle/</link>
		<comments>http://infrequently.org/2008/07/uxebu-hangs-their-shingle/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:28:39 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=684</guid>
		<description><![CDATA[Several Dojo&#8217;s most prolific European contributors have banded together to form Uxebu, a new consultancy centered around Dojo and JavaScript (blog here). SitePen recently expanded to the UK and while we&#8217;re doing lots of business in the EU, it&#8217;s an exciting time to be working with Dojo as the demand is very high. I&#8217;m tremendously [...]]]></description>
			<content:encoded><![CDATA[<p>Several Dojo&#8217;s most prolific European contributors have banded together to form <a href="http://uxebu.com/">Uxebu</a>, a new consultancy centered around Dojo and JavaScript (<a href="http://blog.uxebu.com/">blog here</a>). SitePen recently expanded to the UK and while we&#8217;re doing lots of business in the EU, it&#8217;s an exciting time to be working with Dojo as the demand is very high. I&#8217;m tremendously excited to see that Nikolai, Wolfram, and Tobias are stepping in to help fill the need! Given the quality and quantity of their contributions to Dojo, I expect great things of their new firm.</p>
<p>Congrats guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/07/uxebu-hangs-their-shingle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Firefox 3 Arrays: No, You&#8217;re Not Insane</title>
		<link>http://infrequently.org/2008/02/firefox-3-arrays-no-youre-not-insane/</link>
		<comments>http://infrequently.org/2008/02/firefox-3-arrays-no-youre-not-insane/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 09:41:23 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=651</guid>
		<description><![CDATA[I just spent 20 minutes in IRC with Wolfram staring down one of those situations where you keep swearing under your breath &#8220;println isn&#8217;t broken&#8230;.println isn&#8217;t broken&#8230;.println is NOT broken&#8221;. Catch this fun gem from FF3b2: >>> typeof [] "object" >>> var a = []; >>> var b = new Array(); >>> a.constructor == b.constructor [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent 20 minutes in IRC with Wolfram staring down one of those situations where you keep swearing under your breath &#8220;println isn&#8217;t broken&#8230;.println isn&#8217;t broken&#8230;.println is NOT broken&#8221;.</p>
<p>Catch this fun gem from FF3b2:</p>
<pre><code>
>>> typeof []
"object"
>>> var a = [];
>>> var b = new Array();
>>> a.constructor == b.constructor
false
>>> c = [];
[]
>>> c.constructor == a.constructor
true
>>> d = new Array();
[]
>>> b.constructor == d.constructor;
true
>>> b.constructor == a.constructor;
false
</code></pre>
<p>WTF?</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/02/firefox-3-arrays-no-youre-not-insane/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Big Questions On IE8&#8242;s Big Progress</title>
		<link>http://infrequently.org/2008/02/big-questions-on-ie8s-big-progress/</link>
		<comments>http://infrequently.org/2008/02/big-questions-on-ie8s-big-progress/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 04:20:53 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[dhtml]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[openweb]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=647</guid>
		<description><![CDATA[So IE is the first browser out of the gate to do something sane about rendering engine locking to content&#8230;and good on them for it. Now we need to know a couple more details to see if it&#8217;s going to have real legs: What is the precedence for resolution of conflicting rules? If the compatible [...]]]></description>
			<content:encoded><![CDATA[<p>So IE is the first browser out of the gate to do <a href="http://blogs.msdn.com/ie/archive/2008/01/21/compatibility-and-ie8.aspx">something sane about rendering engine locking to content</a>&#8230;and good on them for it.</p>
<p>Now we need to know a couple more details to see if it&#8217;s going to have real legs:</p>
<ul>
<li>What is the precedence for resolution of conflicting rules? If the compatible rule is provided as an HTTP header and as a meta tag, which wins? If multiple tags occur, is it first or last wins?</li>
<li>If a rule is provided that ignores IE (assuming other renderers follow suit), and a subsequent meta tag shows up which specifies a rule for IE, will IE handle it correctly?
<p>For instance, if the following occurs in a document:</p>
<p><code><br />
&lt;meta http-equiv="X-UA-Compatible" content="FF=3" /&gt;<br />
...<br />
&lt;meta http-equiv="X-UA-Compatible" content="IE=8" /&gt;<br />
</code></p>
<p>What policy will IE use?
</p>
</li>
<li>Will there be any way to specify the box-model behavior on a sub-page basis?</li>
<li>Will the IE 8 rendering engine now be distributed to users of the IE 7 chrome, invoking itself only when the right meta flags are thrown? And what is Microsoft&#8217;s policy toward distributing renderers now that they have logically cut the chrome/renderer chord?</li>
<li>Where will you be standardizing this convention? When?</li>
</ul>
<p>These questions need to be answered, and soon. If the IE team has just replaced <a href="http://alex.dojotoolkit.org/?p=644">one scarce resource for another</a>, we&#8217;re not much better off over the long haul. It&#8217;s great news that the IE team is really implementing the &#8220;renderer selection switch&#8221; which many of us have dreamed of for so long&#8230;but having it continue to be global to the page or in other ways encourage contention on yet another single element in the document wouldn&#8217;t be stepping forward enough.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/02/big-questions-on-ie8s-big-progress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How IE Mangles The Design Of JavaScript Libraries</title>
		<link>http://infrequently.org/2008/01/how-ie-mangles-the-design-of-javascript-libraries/</link>
		<comments>http://infrequently.org/2008/01/how-ie-mangles-the-design-of-javascript-libraries/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 12:21:18 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[openweb]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=644</guid>
		<description><![CDATA[A lot of hyperbole gets thrown around about how painful IE 6 and 7 make the world of JS development, and so I thought I&#8217;d do a bit of cataloging to help those using Dojo understand why it&#8217;s built the way it is and indeed, why all JS widget libraries suffer similar design warts. I [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of hyperbole gets thrown around about how <a href="http://alex.dojotoolkit.org/?p=620">painful IE 6 and 7 make the world of JS development</a>, and so I thought I&#8217;d do a bit of cataloging to help those using Dojo understand why it&#8217;s built the way it is and indeed, why all JS widget libraries suffer similar design warts. I know the good folks up in Redmond are <a href="http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx">working hard at delivering something better</a>, but the fact of the matter remains that until they outline when we&#8217;re going to get it (and the version after) and how it&#8217;s going to be distributed, IE 8 only serves to make the current situation look as shabby as it really is. Here are but 5 examples of how IE makes your toolkit of choice less elegant than it probably should be.</p>
<ol>
<li>
<h4>Array&#8217;s Can&#8217;t Be Usefully Subclassed (<a href="http://alex.dojotoolkit.org/08/jscript/array_weirdness.html">test case</a>)</h4>
<p>At first blush, this seems wrong. You can use the Array base-class as the prototypal delegate for any user-defined class you wish. Methods are correctly delegated to and hash-style indexes work fine. Almost everything works right&#8230;except when you try to use the built-in array manipulation methods like <code>push</code>, <code>pop</code>, and <code>shift</code>. They dutifully change the internal contents of the subclass instance&#8217;s indexed attributes, but they don&#8217;t manipulate the length property. This means that while you can use <code>for(var x in list){ ...</code> style iteration, you can&#8217;t do anything *aside from key iteration* to know how many items are in the array. Obviously, one could try to wrap the intrinsic functions and detect how they manipulate the length property, but then you&#8217;ve ruined their <code>[DontEnum]</code> status and now they end up in the iterable surface area of instances. Ugg.</p>
<p>Arrays without a working <code>length</code> property are nearly useless, and JScript mangles the design of toolkits as a result.</p>
<p>So how do we get <code>dojo.NodeList</code> to be a &#8220;real&#8221; array with extra methods then?</p>
<p>As you might expect, it&#8217;s a giant hack. When you use the &#8220;new&#8221; keyword with the <code>dojo.NodeList</code> function, you expect that the system will create a new instance and do it&#8217;s normal &#8220;stamp with a constructor&#8221; business. Instead, we resort to creating (and populating) a regular Array instance and <a href="http://trac.dojotoolkit.org/browser/dojo/trunk/_base/NodeList.js">&#8220;NodeList-ifying&#8221; it by copying named attributes from the class prototype into the instance as member properties</a>. The &#8220;constructor&#8221; function then explicitly return a new object, bypassing the &#8220;new&#8221; keyword&#8217;s create/stamp machinery, at which point the return of the <code>new</code> operator becomes our explicit return and not the object which it would have otherwise implicitly returned.</p>
<p>In Dojo 0.9 we had used an even more <a href="http://trac.dojotoolkit.org/browser/tags/release-0.9.0/dojo/_base/NodeList.js">aggressively hackish workaround for IE</a> which involved creating a sub-document and mapping <em>its</em> interpreter&#8217;s intrinsic Array class into the parent document at a different name. Both are slow for different reasons but we eventually switched to the create-and-mix-in style because some popup blockers were interfering with the old method.</p>
<p>Lest you think that Dojo is a dirty, dirty toolkit for doing this kind of thing, consider the janktastic &#8220;it&#8217;s not really an array&#8221; thing that JQuery resorts to instead. By giving up all &#8220;[]&#8221; index operations, JQuery manually maintains it&#8217;s internal length property by re-implementing all of <code>push</code>, <code>pop</code>, etc. functions. This has the benefit of allowing prototypal delegation to work of pre-existing instances when new features are added to the base prototype, but at the expense of no longer being able to think about a dense list of things as an array. Dojo&#8217;s approach is painful, but so are all the alternatives today.</p>
<p>I think it&#8217;s safe to say that both toolkits would subclass Array directly to save code, were it a reasonable thing to do.</p>
</li>
<li>
<h4>Where Art Thou Getters/Setters?</h4>
<p>As JavaScript toolkits get pushed out of their current workhorse tasks of plastering over JavaScript and DOM implementation gaffes by positive browser progress and Moore&#8217;s Law, they increasingly take on application construction tasks (e.g., <a href="http://download.dojotoolkit.org/release-1.0.2/dojo-release-1.0.2/dojox/data/demos/demo_MultiStores.html"><code>dojo.data</code></a>). As the toolkits have approached these tasks, we&#8217;ve collectively started to hit some very serious usability limitations due, in large part, to JScript&#8217;s lack of progress.</p>
<p>Toolkits like Dojo have widget systems because HTML just hasn&#8217;t kept up. That means that these toolkits have a responsibility to keep as many of the positive aspects of the &#8220;native&#8221; web as they can. From <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/themes-and-design">CSS customization</a> to <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/a11y">accessibility</a> all the way through <a href="http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/understanding-parser">implementing declarative creation</a> and DOM-ish JavaScript APIs, the better a job a toolkit can do in making the abstraction feel more solid, the better the toolkit is. Widgets are essentially a way to &#8220;subclass HTML elements&#8221;.</p>
<p>In many places, DOM allows you to affect the behavior of the visible document using &#8220;setter&#8221;-style syntax. For example:</p>
<pre><code>
document.getElementById("foo").style.border = "5px dotted black";
</code></pre>
</p>
<p>Custom widget classes <a href="http://developer.mozilla.org/en/docs/defineGetter">can have the same behavior</a> <em>on every browser except IE</em>.
</p>
<p>This means, of course, that JavaScript toolkits can&#8217;t really implement the behavior, backing JavaScript programmers up against a wall when they design their tools. Instead of providing the natural property-oriented behavior, it forces class authors to write <code>getSomeProperty/setSomeProperty</code> method pairs on their classes should they want to do anything when values are gotten or set. The resulting code feels a lot more like Java than JavaScript, which is usually a sign that something is horribly wrong in a browser.</p>
<p>As bad as this problem is for visual widgets, it&#8217;s worse for data binding systems. API&#8217;s like <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/data-retrieval-dojo-data-0"><code>dojo.data</code></a> would be designed in fundamentally different ways if getters and setters were available everywhere. Instead of the rigamarole of making users fetch an item reference and then fetch attribute values using the opaque item handle and the property name, we&#8217;d just set up getters and setters on the properties themselves and defer the implementation of fetching those values down to the data store. Further, assigning a linkage between a <code>dojo.data</code> query or store and a widget which represents it could be as simple as assigning a property to the widget object.</p>
<p>So are workarounds to this possible? I think they are, and I&#8217;m testing some of them out for use in Dojo 1.1 right now. I&#8217;ll post more about them should they pan out. Every avenue which looks potentially workable right now involves <a href="http://alex.dojotoolkit.org/08/jscript/lettable.html">gigantic hacks</a> which also deeply constrain API designs. Fundamentally, this problem can&#8217;t be solved without good language-level support.</p>
<p>It&#8217;s perhaps folly to assume that this will be addressed in IE 8, but given the enormous back-pressure of nearly every JavaScript toolkit author demanding this feature and the embarrassment of every other browser beating them to the punch, I have some hope that we could see getters and setters for JScript in the near future. It won&#8217;t matter much, though, unless the JScript team ships their new engine to <em>all</em> IE versions when they release IE 8. Not bloody likely.</p>
</li>
<li>
<h4>Performance</h4>
<p>Kudos are in order to the JScript team for <a href="http://erik.eae.net/archives/2007/12/14/20.07.27/">fixing</a> their <a href="http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx">long-b0rken</a> GC heuristic and pushing it out to everyone&#8230;but it&#8217;s the tip of the iceberg.</p>
<p>Performance is one of those areas where differences in implementations can tightly circumscribe what&#8217;s possible despite exacting spec conformance. On this front, JScript&#8217;s <a href="http://www.codinghorror.com/blog/archives/001023.html">raw VM-level execution time</a> leaves a lot to be desired, but the true travesties really show up when you hit the DOM for computed style information or try to do anything reasonably complicated that involves string operations.</p>
<p>Most non-trivial blocks of JS code today rely on <code>innerHTML</code> to bootstrap some new chunk of DOM in response to user action due in large part to the cross-browser speed and size advantages of <code>innerHTML</code> vs. raw DOM methods for equivalent DOM structures. This reality pushes IE&#8217;s string performance woes to the fore as more and more client-side systems push far enough to hit the new &#8220;wall&#8221;.</p>
<p>Similarly, getting computed box model calculations out of IE is not for the faint of optimization foo. When we profiled Dojo&#8217;s widgets to plan our attack for 0.9 and 1.0, we noted very quickly that getting box-model data out of the browser for any element is hugely costly on every browser, but on IE the cost was not just big&#8230; it was <em>enormous</em>. Our best guess right now is that the properties on the currentStyle property are re-calculated when they&#8217;re requested from script and not cached in the bound object when layout happens. The resulting performance penalty requires that developers nearly never manage layout in code, severely constraining the layouts which are attempted by toolkits like Dojo.
</p>
<p>Across the board, from DOM performance to raw JScript execution speed, IE is a dog, and the odds are good that whatever toolkit you&#8217;re using spends a lot of time working around that reality.
</p>
</li>
<li>
<h4>Doctype Switching</h4>
<p>Doctype switching to toggle box-model behavior is perhaps the single most limiting implementation error in IE. <a href="http://www.mozilla.com/en-US/firefox/">Saner</a> browsers allow you to use a CSS property to affect the layout model in use in a particular section of a document. This makes tons of sense in a templated world where most of the markup your system generates starts and ends in the &#8220;news hole&#8221;. Today, that covers nearly everyone. A quick line count in any HTML document shows that doctypes are a <em>scarce resource</em> whose scarcity is made problematic when it&#8217;s semantics are overloading. I&#8217;ve been on product teams where the idea of changing the doctype would require months to recover from. That kind of cost related to what should be simply a markup dialect change (not a formatting policy change) implies strongly that the doctype is a terribly brittle way to control several independent concerns.
</p>
<p>Instead of giving devs fine-grained layout system control, IE makes it all-or-nothing. The global flag approach backs toolkit developers into doing script-based layout calculations or &#8220;just throw it in another div&#8221; solutions where we&#8217;d really rather not. Both are slow and both may be required since it&#8217;s completely impractical to dictate to users which doctype they&#8217;ll be using. While any app may be able to be disciplined enough to not care, toolkit developers must work everywhere. Hilarity ensues.
</p>
<p>I fear this is going to get even worse with IE8 as the IE team looks to implement some of HTML 5 and hopefully many of CSS 2.1&#8242;s clarifications. The sooner they abandon the global switch, the better&#8230;but I&#8217;ll wager it&#8217;s pain they just don&#8217;t feel. Building a browser is a very different pursuit from building portable apps to run inside it.</p>
</li>
<li>
<h4>HTC&#8217;s Can&#8217;t Be Inlined (Even With Hacks)</h4>
<p>Modern browsers have built-in widget systems. On IE, it&#8217;s <a href="http://msdn2.microsoft.com/en-us/library/ms531428(VS.85).aspx">HTCs + Viewlink</a> and on Firefox it&#8217;s <a href="http://developer.mozilla.org/en/docs/XBL:XBL_1.0_Reference">XBL</a>. Even a cursory reading through the docks for both is enough to illuminate the gigantic overlap. Alas, no one is yelling at them to standardize and the result is a terrible mess in which both sub-optimal formats limp along with nearly zero Open Web usage.
</p>
<p>So why do I single out IE for whipping here when XBL is just as lame and similarly b0rken with regards to single-file embedding? Well, on Mozilla, you have a lot more &#8220;outs&#8221;. I strongly suspect that you can use &#8220;<a href="http://en.wikipedia.org/wiki/Data:_URI">data:</a>&#8221; urls to generate and evaluate component definitions for FF, which would enable compiling down from a single (more sane) format in the running page environment. IE prevents any such useful code-loading approaches, meaning you have to generate files on disk in their b0rken-ass format in order to be able to use them. Given <a href="http://dojotoolkit.org">how far we&#8217;ve gotten</a> with non-builtin widget systems, it&#8217;s pretty clear that toolkit authors aren&#8217;t going to contort themselves into requiring a build step that splats files all over disk just so that we can give IE and Mozilla different views of the same component description. Instead, we all limp along on our own class hierarchies without any of the benefits of element subclassing, getter/setter handling, and inline (scoped) method description that these browser-provided systems would allow. It&#8217;s kind of pitiful, really.
</p>
<p>IE8 may include strong &#8220;data:&#8221; URL support given that it&#8217;s needed to <a href="http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx">pass Acid2</a>, but I&#8217;m not holding my breath. I strongly suspect that HTC&#8217;s are a dark, unloved corner of the Trident codebase that none of the current engineering team are really fired up about fixing (which they could have done by just allowing Data Islands to contain HTC definitions&#8230;but I digress). The takeaway here is that we probably <em>shouldn&#8217;t even need JS toolkits to build widget systems</em>, but it&#8217;s too late now. We&#8217;re an abstraction short and a decade late and now the Flex frankenstein is beating HTML at it&#8217;s own game.
</p>
</li>
</ol>
<p>In a vacuum of feature data or builds to work with, it&#8217;s prudent to assume that IE 8&#8242;s DOM and JavaScript implementations will continue to warp attempts at building useful, idiomatic JavaScript libraries to ease the problems that HTML + CSS aren&#8217;t effectively solving. So next time you wonder why your toolkit of choice is built the way it is or why it&#8217;s even necessary, just remember that in many cases they are protecting you from a decade or more of bad decision making.</p>
<p>From that perspective, they&#8217;re worth <a href="http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE">every penny</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://infrequently.org/2008/01/how-ie-mangles-the-design-of-javascript-libraries/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

