<?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>O&#039;Reilly Radar &#187; Brett McLaughlin</title>
	<atom:link href="http://radar.oreilly.com/brett/feed" rel="self" type="application/rss+xml" />
	<link>http://radar.oreilly.com</link>
	<description>Insight, analysis, and research about emerging technologies</description>
	<lastBuildDate>Fri, 17 May 2013 16:29:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>What is HTML5?</title>
		<link>http://radar.oreilly.com/2011/07/what-is-html5.html</link>
		<comments>http://radar.oreilly.com/2011/07/what-is-html5.html#comments</comments>
		<pubDate>Wed, 13 Jul 2011 13:00:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[@home]]></category>
		<category><![CDATA[@top]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[linked]]></category>
		<category><![CDATA[Radar Report]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2011/07/what-is-html5.html</guid>
		<description><![CDATA[HTML5, when used both as the 21st century web suggests and as the original HTML specification allows, is best at interconnecting things. ]]></description>
				<content:encoded><![CDATA[<div style="width: 250px;float: right;margin: 3px 0 10px 10px;padding: 2px 4px 0 15px;border-left: 1px solid #ddd">
<p style="background: #990000;width: 250px;color: #fff;font-size: .9em;font-weight: bold;padding: 2px 0 2px 4px;margin: 0 0 3px 0">Sections</p>
<ul style="margin-top: 10px;padding-right: 4px">
<li> <a href="#first-principles">A return to first principles</a></li>
<li> <a href="#still-connecting">HTML5: Still connecting things</a></li>
<li> <a href="#rich-media">HTML5 connections are the new rich media</a></li>
<li> <a href="#javascript">JavaScript isn&#8217;t the focus of HTML5 &#8230; right?</a></li>
<li> <a href="#container-web-pages">Container-based web pages: A step (sort of) in the right direction</a></li>
<li> <a href="#canvas">The canvas element is a programmable div</a></li>
<li> <a href="#mobile">Mobile: Killer application, ho-hum client</a></li>
<li> <a href="#closing">&#8230; and a partridge and a pear tree</a></li>
</ul>
<p><a href="http://oreilly.com/catalog/9781449308148"><img src="http://s.radar.oreilly.com/2011/07/13/0711-whatishtml5-cover.png" border="0" width="250" alt="What is HTML5" /></a></p>
<p align="center"><a href="http://oreilly.com/catalog/9781449308148">Download this report for free</a></p>
</div>
<p>HTML5: Everyone&#8217;s using it, nobody knows what it is. I realize that sounds more like a line out of an existential movie &mdash; maybe <em>Waiting for Godot</em> or a screenplay by Sartre &mdash; than a statement about HTML5. But it&#8217;s really the truth: most of the people using HTML5 are treating it as HTML4+, or even worse, HTML4 (and some stuff they don&#8217;t use). The result? A real delay in the paradigm shift that HTML5 is almost certain to bring. It&#8217;s certainly not time to look away, because by the time you look back, you may have missed something really important: a subtle but important transition centered around HTML5.</p>
<p>In this post, I want to take a deeper look at HTML5. I have a simple proposition with a lot of complex consequences: HTML5 is both something entirely new, and yet nothing more than HTML was ever intended to be; and that once you really understand HTML5, you&#8217;ll change the way you code and even think about the web and your own web applications.</p>
</p>
<h2 id="first-principles">A return to first principles</h2>
</p>
<p>HTML has always been about interconnection. Back in the ancient days, when electronica was cool and <em>not</em> called &#8220;house music&#8221; and before the Rolling Stones qualified for Medicare, the web was littered with big huge documents. In fact, it was exactly the opposite of today, where most people think enhanced digital books are just electronic wrappers around full-text copies of what&#8217;s in print.</p>
<p>In the &#8217;90s, the web was full of 15-page specifications, all in a single file. You scrolled through those massive documents just like you paged through an encyclopedia. Much of the early versions of HTML were intended to deal with this, widely considered a detriment to the readability and usability of the web. That&#8217;s largely because Tim Berners-Lee, the recognized father of HTML, was a researcher enabling other researchers (mostly at CERN at the time). If you&#8217;ve ever known anyone mired in research, brevity is rarely their prevailing trait, so reading huge documents online was a necessity, but scrolling through 15- (or 1,500-) page documents just wasn&#8217;t a long-term option. </p>
<p>So early on, HTML was not primarily about displaying those documents with lots of formatting. Most fundamental to HTML was the simple <span class="code">a</span> tag. It gave a document the means to link to another document. Suddenly 15-page documents were reduced (mercifully) to 15 one-page documents, all linked together. Bye bye scrolling; hello useful linking. This is all pretty standard fare, and if much of this is new to you, then the waters are going to get deep quickly. </p>
</p>
<h2 id="still-connecting">HTML5: Still connecting things</h2>
</p>
<p>Fast forward to the present. Ultimately, this ability to connect things on the Internet is still the primary feature of HTML5. It&#8217;s just that now, we&#8217;re starting to realize the original vision of HTML, and connect a lot more than hypertext with static images. So the introduction of the <span class="code">audio</span> and <span class="code">video</span> elements in HTML5 are nothing more than logical extensions of the old <span class="code">a</span> element.</p>
<p>(Note: in a more correct sense, <span class="code">audio</span> and <span class="code">video</span> replace <span class="code">object</span> and all the embed code that people have been throwing into web pages for years, largely pulled from sites like YouTube or Vimeo. Still, those elements are semantically functioning more like an a element that drops the link into a page, rather than taking you off to another destination. In that sense, even the <span class="code">img</span> element is in some ways nothing more than an inline <span class="code">a</span> element: it grabs content from another location and pulls that content into a page. It&#8217;s all just linking, and that&#8217;s what HTML is really about: linking and connecting things.)</p>
<p>So now you can pull in images, audio, and video directly into a document. More importantly, because those items now have first-order elements, you can easily manipulate the audio and video from JavaScript. That&#8217;s a big deal, and something I&#8217;ll come back to later. In a nutshell, a first-order element is always going to encourage more direct programmatic access than one in which you have to be sneaky or clever to really get at it.</p>
<p>So while the <span class="code">audio</span> and <span class="code">video</span> elements are new, their purpose isn&#8217;t. HTML5 allows you to integrate more assets into a single document, all while keeping the integrity and separation of those assets into place. This is nothing more than making sure that the bibliography of a document isn&#8217;t physically stuck at the end of a long web page, but is in fact separate and easily maintained, but still able to be integrated into the rest of the page.</p>
<p>Now, before moving on, you need to immediately see that it&#8217;s not (relatively) important that you can grab audio and video and drop it into an HTML page. What is important is that you can more easily grab &#8220;other stuff&#8221; and drop it into a page. There may eventually be 20 or 25 elements for things well beyond &#8220;audio&#8221; and &#8220;video,&#8221; and the fundamental premise is still the same: the important thing here is that multiple pieces in multiple places can all be wired together in a meaningful way, with semantic elements describing that &#8220;stuff&#8221; easily accessible by JavaScript. The fact that, in HTML5, that &#8220;other stuff&#8221; happens to be audio and video is cool, but rather incidental.</p>
<div style="float: left;border-top: thin gray solid;border-bottom: thin gray solid;padding: 20px;margin: 20px 2px"><a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-html5"><img style="float: left;border: none;padding-right: 10px" src="http://s.radar.oreilly.com/oscon-code-os11rad.png" /></a><a href="http://www.oscon.com/oscon2011/public/schedule/topic/Javascript%20&amp;%20HTML5?cmp=il-radar-os11-what-is-html5"><strong>OSCON JavaScript and HTML5 Track</strong></a> &mdash; Discover the new power offered by HTML5, and understand JavaScript&#8217;s imminent colonization of server-side technology.</p>
<p>  <a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-html5"><strong>Save 20% on registration with the code OS11RAD</strong></a></div>
</p>
<h2 id="rich-media">HTML5 connections are the new rich media</h2>
</p>
<p>So what, then? Why is this such a big deal? Well, largely for three reasons:</p>
<ol>
<li> <strong>Web pages no longer need to look (and act) like web pages.</strong> The rise of Flash over the last years has largely been an attempt to overcome &#8220;limitations&#8221; of what HTML allows. Flash was initially often focused on animations and cool visual effects. But then entire sites got rolled into Flash, allowing for different types of navigation and page organization, richer programmatic access to the individual pieces of a web page, and the ability to avoid the quirkiness of JavaScript. (I&#8217;ll leave out the obligatory comment here on the quirkiness of the Flash stack.)</li>
<li> <strong>Web pages no longer need to represent one person/organization&#8217;s content.</strong> Even though web programmers and designers have been pulling in images from other sites for years, web pages are still largely homogenous in terms of the asset ownership. A web page today really has one person&#8217;s content, images, pages, media, and the like. Even sites like Vimeo and YouTube are more often used as extensions of a private repository than an actual free medium for world access.</li>
<li> <strong>Web pages can function intelligently and easily across display devices.</strong> It&#8217;s no secret that MOBILE (as one co-worker recently email-shouted at me) is the banner under which HTML5 most often flies. But the story really isn&#8217;t that HTML5 has great mobile support; rather, it&#8217;s that mobile is no longer a problem child. In other words, the story is that what works on a desktop browser pretty much works on a phone. (The list of things not covered by &#8220;pretty much&#8221; is shrinking every few weeks, so better to not list them here and appear outdated next month.) Put another way, phones and tablets are first-class citizens, because they are privy to the same interconnections listed above. In fact, it&#8217;s probably not too meta-physical to say that in addition to inter-connecting content, HTML5 has a really good shot at interconnecting all the devices floating around &#8230; and that&#8217;s arguably at least as big a deal as what it does for content and web applications.</li>
</ol>
<p><img src="http://s.radar.oreilly.com/2011/05/24/0511-html5-logo.png" border="0" alt="HTML5 logo" width="178" style="float: right;margin: 3px 0 10px 10px" />HTML5 introduces &mdash; although it&#8217;s not at all complete in its support for &mdash; a paradigm that moves away from both of these limitations. First, HTML5 and CSS3 provide for JavaScript a pretty solid working set of tools and effects, comparable to most Flash websites. I can generally take a medium-sized Flash website and recreate it in WordPress, HTML5, JavaScript (via jQuery), and CSS3 in a week, if not less. And the upside is enormous: text is again selectable, bookmarking works without lots of weird tricks, and of course website owners can actually update their own sites, rather than relying on some overly busy Flash programmer to help. </p>
<p>The result is that HTML5 is again the most usable and indexable tool available for web content; but that content is richer than ever before. Further, that content no longer has to be owned to the degree that older web pages had to be owned. For a lot of emotional and psychological reasons, mainly, the <span class="code">audio</span> and <span class="code">video</span> elements suggest pulling assets from other sources more than the more generic <span class="code">object</span> element does. There&#8217;s something about seeing <span class="code">video</span> that screams, &#8220;Grab some video and stick it in your page!&#8221; But since there will always be at least an order of magnitude greater number of web page creators than video makers, how do you get that video? You grab it from someone else, hopefully someone who&#8217;s used a nice Creative Commons license. The same is true for <span class="code">audio</span>, of course: you can connect to someone else&#8217;s audio incredibly easily, and so you should. And as already intimated, the audio and video that plays on your desktop browser also plays pretty well on an HTML5-enabled phone or tablet.</p>
<p>Underneath these limitation-stripping observations is something much bigger: content creators are moving from creating completely original content to amalgamating and assembling content. Sure, this isn&#8217;t anything technically new, but it is something that&#8217;s happening more due to the introduction of HTML5 elements like <span class="code">audio</span> and <span class="code">video</span>. And when the web starts to grow in its interconnectedness, it takes a giant step toward the world of Neal Stephenson and &#8220;<a href="http://en.wikipedia.org/wiki/Snow_Crash">Snow Crash</a>&#8221; and &#8220;<a href="http://en.wikipedia.org/wiki/Neuromancer">Neuromancer</a>,&#8221; doesn&#8217;t it? One person creates a video and doesn&#8217;t have to place it or build out a web page. They just throw it on a content-sharing medium like YouTube or Vimeo. Another person goes beyond a simple off-page link but actually integrates that video (fully accessible and mutable via JavaScript, something we&#8217;ll get to shortly) into a web page. Neither person has to be an expert outside of their own domain (video and web page, respectively), but the result is a fusion of assets.</p>
<p>Now expand the working set of that fusion by a factor of 1,000. Or 1,000,000. Throw in <a href="http://radar.oreilly.com/2010/06/what-is-data-science.html">data science</a> and the ability to find, organize, and even localize data like never before. Access that data not just from one browser, but all the major browsers, on all the major devices &mdash; laptops, netbooks, tablets, and phones. Toss in unbelievably cheap data storage, and then realize that we&#8217;ve yet to mention the increased power of JavaScript, the <span class="code">canvas</span> tag and its ability to further manipulate the referenced audio and video, and web messaging, and you&#8217;ll quickly forget that <em>we&#8217;re talking about HTML here, not a traditional high-end programming language like Java or PHP!</em></p>
</p>
<h2 id="javascript">JavaScript isn&#8217;t the focus of HTML5 &#8230; right?</h2>
</p>
<p>That greater ability of HTML5 pages to do a lot more brings JavaScript into focus. Honestly, there&#8217;s not much in HTML5 that specifically speaks to JavaScript. Yes, the HTML5 draft, <a href="http://www.w3.org/TR/2011/WD-html5-diff-20110405/">according to the W3C</a>, is intended to replace the JavaScript APIs detailed in older HTML4, XML1, and DOM Level 2 documents. But no, don&#8217;t expect the JavaScript language to be radically, or even that noticeably, changed in HTML5. Yet hang around the web programming water cooler, and you&#8217;ll hear more about JavaScript than ever before. So what gives?</p>
<p>Well, first of all, HTML5 adds several important new first-order elements, as already mentioned. <span class="code">audio</span> and <span class="code">video</span> are key, as is another element we&#8217;ll get to, <span class="code">canvas</span>. That means that it no longer takes a lot of <span class="code">document.getElementsByTagName(&#8220;object&#8221;)</span> or ID-tagging of <span class="code">object</span> elements to work with media in a web page. Extending that, these elements (unlike the <span class="code">object</span> element) have media-specific attributes like <span class="code">autoplay</span> and <span class="code">preload</span>. This means that with JavaScript, you can grab a video, display its controls, change the URL and effectively load a new video, and even control when the video loads (or preloads) and mute and unmute the audio.</p>
<p>All of this is done via JavaScript, but there&#8217;s nothing new <em>in</em> JavaScript enabling this access. It&#8217;s the addition of semantically meaningful elements in HTML5 that makes JavaScript more powerful, or at the least an easier medium in which to accomplish these tasks. Sure, a clever JavaScript programmer (who was comfortable tokenizing and parsing) could get most of this from grabbing particular attributes from an <span class="code">object</span> element, adjust them, reset them, and so on. But my goodness, it was a mess, it was player-specific, and mostly made for annoying late nights trying to get the semicolon in just the right place.</p>
<p>In fact, much of what&#8217;s great, albeit seemingly boring, about HTML5 is the move of important elements and attributes from customized or one-off items to semantically important ones. Even the <span class="code">draggable</span> attribute &mdash; allowing native drag-and-drop in HTML5 &mdash; is cooler because it&#8217;s now accessible and easily mutated via JavaScript. A page requires less textual data to mean something, and more of that meaning is pushed into the structure of the page itself.</p>
<p>I think it&#8217;s fair to go as far as being axiomatic here: the more a document has semantic meaning, and the less attributes or even elements are nested as plain text within hidden <span class="code">input</span> elements or <span class="code">object</span> embeds, the better that document will be. The page becomes easier to access, update, and make responsive from a JavaScript point of view; CSS (whether it&#8217;s CSS2 or CSS3) can be applied directly without so many messy pseudo- and nested selectors; and the document describes itself. And when you have documents that have semantic meaning, you&#8217;re going to find that your JavaScript is clearer. In fact, many mid-level programmers will realize that they can do things that the &#8220;advanced&#8221; programmers can: throw a video into the page based on a click, autoplay that video, mute the audio and load a different piece of audio, play that different audio over the video, and boom: you&#8217;ve got an all-HTML5 discussion <a href="http://www.youtube.com/watch?v=j9i9N-Ez5Y8">by Hitler about JJ Abrams and Star Trek &#8230;</a> without having to modify the original audio and video assets.</p>
<p>Put another way, the HTML page becomes more of a container (which contains other containers, which contain other containers &#8230; and so on) than a page. JavaScript can easily access those nested containers, and modify them, update them, move them around, and do anything else you can dream up and code. CSS can also visually style and work with those containers, further making the HTML a purely organizational tool, and even that becomes loose. With absolute positioning, the order and position of elements within the HTML organization becomes at best a guide, if not totally irrelevant.</p>
<p>(It&#8217;s worth saying a display approach that completely ignores the organization and sequence of elements within an HTML document is a pretty bad idea. What you gain with new semantically valuable elements is quickly lost when you start absolutely positioning everything, and removing any sense of hierarchy. Of course, that&#8217;s true in HTML4 and XHTML1 as well as HTML5, so it&#8217;s not something I&#8217;ll focus on beyond this rather quick note.)
</p>
<h2 id="container-web-pages">Container-based web pages: A step (sort of) in the right direction</h2>
</p>
<p>The idea of an HTML page being little more than an organization of malleable elements is nothing new, but HTML5 seems to be a clear jumping-in point for JavaScript programmers and web developers that haven&#8217;t yet made that conceptual leap. It&#8217;s notable that with the rise of CMSes like WordPress for smaller businesses and personal websites, almost everyone is now familiar with the separation of concerns involved when even the text of an HTML page isn&#8217;t necessarily encoded and stored within a static HTML file. This is all a good thing, too. As a JavaScript programmer myself, I&#8217;d rather have more programmatic control and create a page that is built based on user decisions, database-driven logic, and programming over one person with an HTML or text editor.</p>
<p>In fact, the most obvious example of this approach is the <a href="http://www.twitter.com">Twitter</a> website. For example, when I visit Twitter, I see a ton of content:</p>
<div align="center">
<p class="image-box-550">
<img src="http://s.radar.oreilly.com/2011/05/24/twitterScreenGrab.png" border="0" alt="Twitter screen grab" width="550" /></p>
</div>
<p>But if you take a closer look, by viewing the source, you&#8217;ll find hundreds of lines of JavaScript at the beginning of the file, a ton more JavaScript at the end of the file, and this rather pedestrian bit of HTML squeezed into the middle. Here&#8217;s about 1/3 of that HTML, which is pretty brief:</p>
<p><code><br />
&lt;![CDATA[<br />
  &lt;body class="user-style-twttr  loading-body "&gt; <br />
    &lt;div id="doc"&gt; <br />
      &lt;div id="top-stuff"&gt;<br />
        &lt;div id="banners" style="clear:both;"&gt;&lt;/div&gt; <br />
        &lt;div id="top-bar-outer"&gt; <br />
          &lt;div id="top-bar-bg"&gt;&lt;/div&gt; <br />
          &lt;div id="top-bar"&gt; <br />
            &lt;div class="top-bar-inside"&gt; <br />
              &lt;div class="static-links"&gt; <br />
  &lt;div id="logo"&gt; <br />
    &lt;a href="/"&gt;Twitter&lt;/a&gt; <br />
  &lt;/div&gt; <br />
  &lt;form id="search-form" action="/search" method="GET"&gt; <br />
    &lt;span class="glass"&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt; <br />
    &lt;input value="" placeholder="Search" name="q" id="search-query" type="text" /&gt; <br />
  &lt;/form&gt; <br />
  &lt;div id="global-nav"&gt; <br />
    &lt;ul&gt; <br />
      &lt;li id="global-nav-home"&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; <br />
          &lt;li id="global-nav-profile"&gt;&lt;a href="/bdmclaughlin"&gt;Profile&lt;/a&gt;&lt;/li&gt; <br />
          &lt;li id="global-nav-messages"&gt;&lt;a href="/messages"&gt;Messages&lt;/a&gt;&lt;/li&gt; <br />
          &lt;li id="global-nav-whotofollow"&gt;&lt;a href="/#!/who_to_follow"&gt;Who To Follow&lt;/a&gt;&lt;/li&gt; <br />
      &lt;/ul&gt; <br />
  &lt;/div&gt; <br />
  &lt;div id="sections"&gt;&lt;/div&gt;]]&gt;<br />
</code></p>
<p>Not a lot to it, is there? Of course, even parts of this have been inserted programmatically, like links to my personal profile and messages. And even though this is an HTML4 site, it points to some important things with which HTML5 is attempting to deal.</p>
<p>Now, what I want to argue is that while this is a generally good thing &mdash; using JavaScript to connect the organization of HTML to content not encoded directly into that HTML &mdash; the step forward of new HTML5 elements is matched, if not overtaken, by some steps back in terms of this sort of programming, at least as it&#8217;s currently implemented. It&#8217;s not exaggeration to say that many pages, like Twitter&#8217;s page, are basically a bunch of empty <span class="code">div</span>s with <span class="code">id</span> attributes and not much else. It&#8217;s unclear whether Twitter&#8217;s page will evolve into a more HTML5-centric approach, but unless it also evolves its structure, there are some problems.</p>
<p>Here&#8217;s the thing: this approach is programmer-rich, yet semantically poor. First, elements aren&#8217;t truly indicating content; they&#8217;re just indicating buckets that can be filled. And don&#8217;t mistake a textual value attached to a <span class="code">div</span>&#8216;s <span class="code">id</span> attribute as semantic meaning. That&#8217;s no different than the <span class="code">object</span> element when used to display audio or video; you&#8217;ve got to parse and tokenize to get any real sense of meaning. That&#8217;s meaning, but it&#8217;s not meaning encoded into the HTML in a particularly useful way.</p>
<p>This is another area that HTML5 seeks to improve. For many, the introduction of another few elements &mdash; <span class="code">nav</span> and <span class="code">header</span> and <span class="code">footer</span>, for example &mdash; have been largely ignored. Why not just keep using <span class="code">&lt;div id=&#8221;nav&#8221;&gt;</span>? Well, now the answer should be obvious: these new elements provide additional semantic meaning. If I&#8217;m linking to your page, or even pulling in part of your page, in my own page, I can grab (or not grab) your footer, your navigation, your figures and figure captions.</p>
<p>Don&#8217;t let the <a href="http://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language">SGML</a>-ness of semantic meaning escape you. (Yes, I realize that SGML-ness isn&#8217;t a word, but it should be.) When you really begin to connect heterogeneous parts of the web together, semantic meaning becomes huge. So does a page that is more than a bunch of <span class="code">div</span>s with <span class="code">id</span> attributes. You&#8217;ll want to know what you&#8217;re getting, and an HTML standard is a heck of a lot better way to determine meaning than arbitrary text values tucked away into <span class="code">id</span> attributes.</p>
<p>By now, you&#8217;re either seeing a theme in what I&#8217;m calling out about HTML5, or you&#8217;re seeing little more than a grab bag of loosely connected features. If you&#8217;re in the latter camp, let me make it explicit: HTML5, when used both as the 21st century web suggests and as the original HTML specification allowed, is best at interconnecting things. If you view your pages as a collection of content, and let go of the rather egotistical idea that all that content has to <em>be</em> your own, then all of the new features of HTML5 discussed so far are hugely important. You can pull in audio and video and manipulate that audio and video as if it were your own. You can organize your page semantically and link to and even pull in content from other sites, using the semantics of that page. You can separate content from organization using more than just <span class="code">div</span>s, but actual first-order elements for navigation and headers and footers.</p>
<p>And then, when things were going so well, there was <span class="code">canvas</span>.</p>
</p>
<h2 id="canvas">The canvas element is a programmable div</h2>
</p>
<p>It&#8217;s odd that the element that is probably at the top of the HTML5 spec in terms of &#8220;wow factor&#8221; is in fact the element that brings in the ability to undo most of the good I think HTML5 does. That element, of course, is <span class="code">canvas</span>. <span class="code">canvas</span> defines, well, a canvas on the HTML page. Using JavaScript, you can draw on that canvas using methods that look a lot like a graphics scripting language. JavaScript basically grabs the <span class="code">canvas</span> by its <span class="code">id</span> attribute, using <span class="code">document.getElementById()</span>, and then gets a <em>context</em>. Most of the examples online that are really jaw-dropping use the 3D canvas, but there&#8217;s a 2D canvas that&#8217;s a lot better entry-point if you&#8217;re new to this sort of thing.</p>
<p>Once you&#8217;ve got a context, you can operate upon that object, using properties like <span class="code">fillStyle</span>, and methods like <span class="code">fillRect(top, left, width, height);</span>, and <span class="code">canvas</span>. Yes, it&#8217;s really that simple, and even pretty intuitive. In fact, more than anything else, drawing on a canvas for the first time with JavaScript felt a lot like my old Logo days in grade school, or even Java AWT days in early Java. (Oddly, I&#8217;m prouder of what I did in Logo than AWT; don&#8217;t judge.)</p>
<p>I don&#8217;t think it&#8217;s worth a lot of ink to walk you through using canvases. There are tons of web tutorials out there in both 2D and 3D, and a slew of <a href="http://oreilly.com/catalog/0636920016502">good video</a> and <a href="http://oreilly.com/catalog/9780596806033/">publications</a>.  Suffice it to say that the days of needing Flash to really do anything visually interesting, or at least needing to take that visually-interesting thing you created and turn it into an image or a video, are gone. What&#8217;s even cooler is that you again get JavaScript integration into your page. So now a keypress or a form submission, or dragging an element on the page, or the playing of a video (because we have <span class="code">draggable</span> and <span class="code">video</span> now, remember?) can interact with the canvases on your page.</p>
<p>Now, there are two caveats: one small one and one giant one. The small one is that browsers are still getting their HTML5 act together, and the 3D context in particular is pushing browsers beyond what they were often intended to do. So realize that while you&#8217;re not going to get the dreaded &#8220;Flash content won&#8217;t play&#8221; sort of message on your iPhone, there is going to be a lot of rigorous testing required to get your 3D drawing just right on the most computers in the most browsers. But, honestly, that&#8217;s a testing issue, and one that both time (as people upgrade) and testing can overcome.</p>
<p>The more serious issue is that the <span class="code">canvas</span> becomes much like an anonymous, programmatically-filled <span class="code">div</span>. The things within it have no semantic meaning and existing apart from the HTML&#8217;s encoding on disk; it&#8217;s a dynamic set of programmatically-created lines and squares and spheres. No matter how cool of a texture you wrap around a 3D model, you can&#8217;t go in with a separate JavaScript function (or better, a separate HTML page) and grab that textured sphere, link to it, spin it around its axis, or adjust the light source. You can do <em>all</em> of those things from the page itself, mind you; you just can&#8217;t do it in the loosely-interconnected manner that is heralding the new and cool web that HTML5 helps drive.</p>
<p>So is this a stump speech against <span class="code">canvas</span>? Of course not. I&#8217;d no more avoid <span class="code">canvas</span> than I&#8217;d tell someone in HTML4 to avoid <span class="code">div</span>. Yes, there is a limit to semantic meaning. Yes, the <span class="code">canvas</span> becomes a big blob that contains something, but that something has minimal outside visibility. But it&#8217;s still a step forward, and heralds what is hopefully a wealth of GPU studs and studettes making HTML5 do far more than anyone thought possible. (Studettes: another made up word, but these are <em>good</em> words. Webster, anyone? Urban Dictionary?)</p>
<p>Hopefully, there will soon be standardized ways to call into objects that are created within a canvas, and granularity becomes part of the advantages of a <span class="code">canvas</span> rather than a drawback. Until then, you&#8217;ve got to decide if using a <span class="code">canvas</span> makes sense. In general, if you&#8217;re doing something page-specific, or if your <span class="code">canvas</span> is itself a self-contained &#8220;mini-application,&#8221; then go forth and prosper. If your <span class="code">canvas</span> is tightly integrated into the rest of your page, you&#8217;re probably in great shape, too. But if you want a lot of other pages and sites to pick up your <span class="code">canvas</span> as any sort of component, you&#8217;re probably out of luck, and might want to look at a different approach.</p>
<p>The good/bad news here is of course, that HTML allows for this sort of reuse, and people are starting to figure that out, but people are <em>just</em> starting to figure this out. Interconnections again; are you building your own little kingdom in the web, complete with moat and drawbridge to keep everyone else out? Or are you integrating everything you do into a larger-than-you Internet that shares (and sometimes steals) as much as it creates, and in that sharing and stealing recreates?</p>
</p>
<h2 id="mobile">Mobile: Killer application, ho-hum client</h2>
</p>
<p>For those of you already read up on HTML5, you may be surprised how little the word &#8220;mobile&#8221; has shown up. Sure, I mentioned earlier that mobile devices can view HTML5 web pages, and consume audio and video from <span class="code">audio</span> and <span class="code">video</span> without many problems. But isn&#8217;t this the big story with HTML5? In fact, isn&#8217;t it mobile devices, more than anything else, that are driving HTML5 adoption?</p>
<p>Well, yes and no.</p>
<p>As far as mobile devices driving adoption, absolutely: HTML5 owes a lot of its buzz to mobile devices, and in particular Steve Jobs and his near-militant campaign against Flash. The iPhone came with Safari, Safari had HTML5 support, so suddenly iPhone users were giddy and talkative. Now almost all modern smartphones have an HTML5-capable browser. So while the ability to view video without Flash is big, the yet-bigger story is simply that anything that works on an HTML5 website as viewed within a desktop browser pretty much works on a phone. So yes, HTML5 wouldn&#8217;t be the talk of the developer town if not for mobile.</p>
<p>But no, mobile can&#8217;t be the big story with HTML5. (People will claim it is, and do so all the time, but they&#8217;re misguided in that they&#8217;re calling an effect a cause.) HTML5 doesn&#8217;t offer all sorts of bells and whistles for working with mobile devices. Yes, there are ways to detect the orientation and screen size of a mobile device; but those also allow for detection of the size of a browser window, or a tablet display. And yes, certainly, the <span class="code">canvas</span> element and new audio and video features make it possible to deliver amazing content to a mobile device. And yes, yet again, more and more folks are building mobile-optimized websites for phones. So how is this not a big deal?</p>
<p>Well, what&#8217;s important is not that HTML5 works on phones. What&#8217;s important is that HTML5 &#8220;just works.&#8221; There aren&#8217;t tons of issues when getting your site to work on a phone &#8230; and <em>that&#8217;s</em> the story. The big deal isn&#8217;t that you can do all kinds of cool things with your website for mobile phones. The big deal is that you can do all kinds of cool things, period; and that those cool things just happen to work on mobile phones &#8230; and tablets &#8230; and netbooks &#8230; and desktop clients. HTML5 really removes the need to think about mobile devices separately from other devices.</p>
<p>(Note: I&#8217;m not saying you should ignore mobile devices, or not think about them separately. The best sites I use on my phone are almost all at least mobile-optimized, if not complete with a pure-mobile theme or CSS styling. That said, you don&#8217;t have to do this to get up and running. Also, almost all good mobile-themed sites have a &#8220;View normal site&#8221; that works perfectly well. That says a lot. It used to be you&#8217;d want to hide the normal site at almost all costs. Not with HTML5&#8230;)</p>
</p>
<h2 id="closing">&#8230; and a partridge and a pear tree</h2>
</p>
<p>As this article turns the bend from readable to monolithic, at least in article terms, it&#8217;s easy to look at what else HTML5 offers, and consider writing an entire book. There&#8217;s web messaging, and offline applications, and local storage &#8230; really, everything you need to write an entire application. And ultimately, that&#8217;s the brief but accurate assessment I&#8217;d make of the &#8220;everything else&#8221; of HTML5. HTML5 is no longer about a single page, or even a collection of inter-linked pages. It&#8217;s about interconnection &mdash; and I&#8217;ve tried to beat that drum consistently above all else &mdash; but that interconnectedness is about a lot more than pages. It&#8217;s certainly about a lot more than just <em>your</em> pages.</p>
<p>Web messaging allows interconnecting HTML5 applications (I&#8217;ll defend the use of &#8220;application&#8221; here in a moment; for now, just go with me). Those applications don&#8217;t have to be in the same domain; for the first time, there&#8217;s an intelligent JavaScript-based messaging framework that allows for communication across domains. You can write listeners to receive messages and senders to send them. In its simplest form, all the limitations of Ajax sandboxing that everyone griped about have been removed, albeit with some security considerations and a lot more complex API than the pretty simple XmlHttpRequest object. But all the same, if you buy into the premise that HTML5 encourages sharing of resources across the web, then messaging makes that sharing more of a true two-way communication. Now you can build resources that can be consumed, even if that consumption involves receiving data as well as sending it.</p>
<p>And you&#8217;ve got local storage, too: a legitimate database-like storage mechanism for holding onto data and delivering it to a server on the Internet when that server is available &mdash; even if that&#8217;s not the &#8220;now&#8221; of the page&#8217;s existence and use by a real person. These tie in closely with forms, the most obvious means of getting this sort of data that local storage is optimized to store. In fact, while it&#8217;s nice that HTML5 forms offer some new controls and validation and the like, it&#8217;s their ability to interact intelligently with offline storage (via, again, JavaScript) that&#8217;s the really big story. Think about that: for the first time in, well, ever, there&#8217;s valuable offline access that can take place. Again, there are kinks (and some of them are big) and some new wrinkles to take into your JavaScript, but the web has always had kinks and wrinkles. It&#8217;s just that now you&#8217;re getting more than ever for dealing with those issues.</p>
<p>Add to that even heavier-duty types of functionality, like <a href="http://www.whatwg.org/specs/web-workers/current-work/">threads (which are called web workers, but really are just threads)</a> and <a href="http://dev.w3.org/html5/websockets/">sockets</a>. On the one hand, these aren&#8217;t part of the core HTML5 spec. Instead, they&#8217;ve been moved into <a href="http://www.whatwg.org/">WHATWG</a>, so that says something about their ultimate inclusion and importance as part of HTML5 to the W3C community. On the other hand, by untying these from the core spec, they may now be free to evolve further and more quickly than ever before. In any case, it&#8217;s no small thing to be talking about threads and sockets not as part of code that generates or produces HTML, but as part of an HTML application itself. These are serious tools, and further indicate that HTML5 is not to be taken as a language for building interesting and largely static web pages anymore.</p>
<p>So about this word <em>application</em>: isn&#8217;t that what&#8217;s ultimately being created with HTML5? This isn&#8217;t just about neat visuals and clever drag-and-drop controls and even replacing Flash-based sites. HTML5 pushes a good programmer to create semantically-meaningful and accessible resources. Those resources don&#8217;t have to be entire pages. They can just be &#8220;things:&#8221; video and audio and navigation and footers. Those &#8220;things&#8221; can not only be used across domains by other &#8220;things,&#8221; but there&#8217;s actually communication that can happen. You can pull in a very well-designed footer by sending it a few choice bits of information, and have that footer pulled from one domain interact with a video pulled from another domain. When the user is offline, big deal. Local storage not only allows for database-like storage of an HTML page <em>without an installed database</em>, but is even kind enough to make sure that data gets to the right place where connectivity is restored. JavaScript is not a toy language anymore, and <a href="http://jquery.com/">jQuery</a> makes what was annoying in JavaScript lexically a piece of cake.</p>
<p>These are applications.</p>
<p>Stop building web pages. Please. Stop trying to only use &#8220;your&#8221; content. Slap a Creative Commons license not just on your video, or your images, but on your HTML, and then build interesting components and assume they&#8217;ll be sucked into other things and used in ways you&#8217;d never considered. It is called the Internet, remember?</p>
<p>The winners in an HTML5 world are those who stop fearing being stolen from, and actually start handing out their candy to every kid on the block. It&#8217;s about a lot more than YouTube-like sharing of videos. Applications are increasingly becoming a collection of mini-applications, and if you&#8217;re thinking about your HTML5 work as collecting resources &mdash; some original, some shared &mdash; then you&#8217;re way ahead of the curve.</p>
<hr />
<p><em>OSCON 2011, coming up later this month, will have a track dedicated to JavaScript and HTML5. <a href="http://www.oscon.com/oscon2011/public/schedule/topic/Javascript%20&amp;%20HTML5?cmp=il-radar-os11-what-is-html5">Learn more</a> and  <a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-html5">save 20% on registration with the codeOS11RAD</a>.</em></p>
<p></p>
<p><strong>Related:</strong></p>
<ul>
<li> <a href="http://radar.oreilly.com/2011/07/what-is-node.html">What is Node.js?</a></li>
<li> <a href="http://radar.oreilly.com/2011/02/flash-html5-developers.html">Can Flash and HTML5 get along?</a></li>
<li> <a href="http://radar.oreilly.com/2011/02/flash-html5-developers.html">Why HTML5 is worth your time</a></li>
<li> <a href="http://radar.oreilly.com/2010/11/new-directions-in-web-architec.html">New directions in web architecture. Again.</a></li>
<li> <a href="http://radar.oreilly.com/2010/11/semantic-web-linked-data.html">Where the semantic web stumbled, linked data will succeed</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2011/07/what-is-html5.html/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>What is Node.js?</title>
		<link>http://radar.oreilly.com/2011/07/what-is-node.html</link>
		<comments>http://radar.oreilly.com/2011/07/what-is-node.html#comments</comments>
		<pubDate>Wed, 06 Jul 2011 13:00:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[@home]]></category>
		<category><![CDATA[@top]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Radar Report]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2011/07/what-is-node.html</guid>
		<description><![CDATA[Learning Node might take a little effort, but it&apos;s going to pay off. Why? Because you&apos;re afforded solutions to your web application problems that require only JavaScript to solve. ]]></description>
				<content:encoded><![CDATA[<div style="width: 250px;float: right;margin: 3px 0 10px 10px;padding: 2px 4px 0 15px;border-left: 1px solid #ddd">
<p style="background: #990000;width: 250px;color: #fff;font-size: .9em;font-weight: bold;padding: 2px 0 2px 4px;margin: 0 0 3px 0">Sections</p>
<ul style="margin-top: 10px;padding-right: 4px">
<li> <a href="#warning">A warning to the Node experts out there</a></li>
<li> <a href="#basic-examples">Node: A few basic examples</a></li>
<p><!-- ul&gt;--></p>
<li> <a href="#skip-hello-world">Skipping hello world</a></li>
</ul>
<li> <a href="#not-javascript">Node runs JavaScript, but isn&#8217;t JavaScript</a></li>
<li> <a href="#node-server">Interacting with a &#8220;Node server&#8221;</a></li>
<li> <a href="#primer">A quick line-by-line primer</a></li>
<li> <a href="#translation">Lost in translation</a></li>
<p><!-- ul&gt;--></p>
<li> <a href="#json">The JSON round trip</a></li>
<li> <a href="#solid-code">Subtlety and nuance destroy solid code</a></li>
<li> <a href="#eval">eval() in JavaScript is (Potentially) the Devil</a></li>
</ul>
<li> <a href="#big-event-web">Today&#8217;s web is a big-event web</a></li>
<p><!-- ul&gt;--></p>
<li> <a href="#data-dump">Sending lots of data at one time</a></li>
<li> <a href="#little-data">Sending a little data at all times</a></li>
<li> <a href="#chaos">Yes, chaos can ensue</a></li>
</ul>
<li> <a href="#right-place">In the right place at the right time</a></li>
<p><!-- ul&gt;--></p>
<li> <a href="#familiarity">The inertia of familiarity</a></li>
<li> <a href="#simplicity">Node&#8217;s promise of simplicity</a></li>
</ul>
</ul>
</div>
<p><a href="http://Nodejs.org/">Node.js</a>. It&#8217;s the latest in a long line of &#8220;Are you cool enough to use me?&#8221; programming languages, APIs, and toolkits. In that sense, it lands squarely in the tradition of <a href="http://rubyonrails.org/">Rails</a>, and <a href="http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications">Ajax</a>, and <a href="http://radar.oreilly.com/2011/01/what-is-hadoop.html">Hadoop</a>, and even to some degree <a href="http://oreilly.com/catalog/9780596806446">iPhone programming</a> and <a href="http://radar.oreilly.com/2010/03/why-html5-is-worth-your-time.html">HTML5</a>. Go to a big technical conference, and you&#8217;ll almost certainly find a few talks on Node.js, although most will fly far over the head of the common mortal programmer.</p>
<p>Dig a little deeper, and you&#8217;ll hear that Node.js (or, as it&#8217;s more briefly called by many, simply &#8220;Node&#8221;) is a server-side solution for JavaScript, and in particular, for receiving and responding to HTTP requests. If that doesn&#8217;t completely boggle your mind, by the time the conversation heats up with discussion of ports, sockets, and threads, you&#8217;ll tend to glaze over. Is this really JavaScript? In fact, why in the world would anyone want to run JavaScript outside of a browser, let alone the server?</p>
<p>The good news is that you&#8217;re hearing (and thinking) about the right things. Node really is concerned with network programming and server-side request/response processing. The bad news is that like Rails, Ajax, and Hadoop before it, there&#8217;s precious little clear information available. There will be, in time &mdash; as there now is for these other &#8220;cool&#8221; frameworks that have matured &mdash; but why wait for a book or tutorial when you might be able to use Node today, and dramatically improve the maintainability of your code and even the ease with which you bring on programmers?</p>
</p>
<h2 id="warning">A warning to the Node experts out there</h2>
</p>
<p>Node is like most technologies that are new to the masses, but old hat to the experienced few: it&#8217;s opaque and weird to most but completely usable for a small group. The result is that if you&#8217;ve never worked with Node, you&#8217;re going to need to start with some pretty basic server-side scripts. Take your time making sure you know what&#8217;s going on, because while this is JavaScript, it&#8217;s not operating like the client-side JavaScript you&#8217;re used to. In fact, you&#8217;re going to have to twist your JavaScript brain around event loops and waiting and even a bit of network theory.</p>
<p>Unfortunately, this means that if you&#8217;ve been working and playing with Node for a year or two, much of this article is going to seem pedestrian and overly simplistic. You&#8217;ll look for things like using Node on the client, or heavy theory discussions on evented I/O and reactor patterns, and <span class="code">npm</span>. The reality is that while that&#8217;s all interesting &mdash; and advances Node to some pretty epic status &mdash; it&#8217;s incomprehensible to someone just getting started out. Given that, maybe you should pass this piece on to your co-workers who <em>don&#8217;t</em> know Node, and then when they&#8217;re buying into Node&#8217;s usefulness, start to bring them along on the more advanced Node use cases.</p>
<div style="float: left;border-top: thin gray solid;border-bottom: thin gray solid;padding: 20px;margin: 20px 2px"><a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-node"><img style="float: left;border: none;padding-right: 10px" src="http://s.radar.oreilly.com/oscon-code-os11rad.png" /></a><a href="http://www.oscon.com/oscon2011/public/schedule/detail/20334?cmp=il-radar-os11-what-is-node"><strong>Node Day at OSCON</strong></a> &mdash; This year&#8217;s OSCON features a day-long dive into Node on Tuesday, July 26. Join experts and users from the Node community to discuss best practices and future developments, and survey the ever-growing number of Node frameworks and plugins.</p>
<p><a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-node"><strong>Save 20% on registration with the code OS11RAD</strong></a></div>
</p>
<h2 id="basic-examples">Node: A few basic examples</h2>
</p>
<p>First things first: you need to realize that Node is intended to be used for running standalone JavaScript programs. This isn&#8217;t a file referenced by a piece of HTML and running in a browser. It&#8217;s a file sitting on a file system, executed by the <span class="code">Node</span> program, running as what amounts to a <a href="http://en.wikipedia.org/wiki/Daemon_(computing)">daemon</a>, listening on a particular port.</p>
<h3 id="skip-hello-world">Skipping hello world</h3>
<p>The classic example here is &#8220;Hello World,&#8221; detailed on the <a href="http://Nodejs.org/docs/latest/">Node website</a>. Almost everyone starts with Hello World, though, so check that out on your own, and skip straight to something a lot more interesting: a server that can send static files, not just a single line of text:</p>
<pre>
	var sys = require("sys"),
	    http = require("http"),
	    url = require("url"),
	    path = require("path"),
	    fs = require("fs");

	http.createServer(function(request, response) {
	    var uri = url.parse(request.url).pathname;
	    var filename = path.join(process.cwd(), uri);
	    path.exists(filename, function(exists) {
	        if(!exists) {
	            response.writeHead(404, {"Content-Type": "text/plain"});
	            response.end("404 Not Foundn");
	            return;
	        }

	        fs.readFile(filename, "binary", function(err, file) {
	            if(err) {
	                response.writeHead(500, {"Content-Type": "text/plain"});
	                response.end(err + "n");
	                return;
	            }

	            response.writeHead(200);
	            response.end(file, "binary");
	        });
	    });
	}).listen(8080);

	console.log("Server running at http://localhost:8080/");
</pre>
<p>Thanks much to <a href="http://twitter.com/mamund">Mike Amundsen</a> for the pointer to similar code. This particular example was posted by Devon Govett on the <a href="http://net.tutsplus.com/">Nettuts+</a> training blog, although it&#8217;s been updated for the current version of Node in a number of places. Devon&#8217;s <a href="http://net.tutsplus.com/tutorials/javascript-ajax/learning-serverside-javascript-with-Node-js/">entire tutorial post</a> is actually a great companion piece on getting up to speed on Node once you have a handle on the basics.</p>
<p>If you&#8217;re new to Node, type this code into a text file and save the file as <em>NodeFileServer.js</em>. Then head out to <a href="http://Nodejs.org/">the Node website</a> and <a href="http://Nodejs.org/docs/latest/#download">download Node</a> or check it out from the <a href="https://github.com/joyent/Node">git repository</a>. You&#8217;ll need to build the code from source; if you&#8217;re new to Unix, <span class="code">make</span>, and <span class="code">configure</span>, then check out <a href="https://github.com/joyent/Node/wiki/Installation">the online build instructions</a> for help.</p>
</p>
<h2 id="not-javascript">Node runs JavaScript, but isn&#8217;t JavaScript</h2>
</p>
<p>Don&#8217;t worry that you&#8217;ve put aside <em>NodeFileServer.js</em> for a moment; you&#8217;ll come back to it and more JavaScript shortly. For now, soak in the realization that you&#8217;ve just run through the classic Unix configuration and build process:</p>
<pre>
./configure
make
make install
</pre>
<p>That should come with another realization: Node itself isn&#8217;t JavaScript. Node is a program for <em>running</em> JavaScript, but isn&#8217;t JavaScript itself. In fact, Node is a C program. Do a directory listing on the <em>Node/src</em> directory and you&#8217;ll see something like this:</p>
<p class="image-box-580">
<a href="http://s.radar.oreilly.com/2011/06/22/node_ls_listing.png"><img src="http://s.radar.oreilly.com/2011/06/22/node_ls_listing-580.png" width="580" border="0" alt="Node ls listing" style="margin-bottom: 15px" /><br />
<a href="http://s.radar.oreilly.com/2011/06/22/node_ls_listing.png">Click to enlarge</a></p>
<p>For all of you thinking that JavaScript is a poor language in which to be writing server-side tools, you&#8217;re half right. Yes, JavaScript is not equipped to deal with operating system-level sockets and network connectivity. But Node isn&#8217;t written in JavaScript; it&#8217;s written in C, a language perfectly capable of doing the grunt work and heavy lifting required for networking. JavaScript is perfectly capable of sending instructions to a C program that can be carried out in the dungeons of your OS. In fact, JavaScript is far more accessible than C to most programmers &mdash; something worth noting now, and that will come up again and again in the reasons for looking seriously at Node.</p>
<p>The primary usage of Node further reflects that while Node works with JavaScript, it isn&#8217;t itself JavaScript. You run it from the command line:</p>
<pre>
 &mdash; (bdm0509@Bretts-MacBook-Pro Sun, 29 May 11) &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash; (/Users/bdm0509/tmp/Node/src) &mdash;
 &mdash; (09:09 $)-&gt; export PATH=$HOME/local/Node/bin:$PATH

 &mdash; (bdm0509@Bretts-MacBook-Pro Sun, 29 May 11) &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash; (/Users/bdm0509/tmp/Node/src) &mdash;
 &mdash; (09:09 $)-&gt; cd ~/examples

 &mdash; (bdm0509@Bretts-MacBook-Pro Sun, 29 May 11) &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash;  &mdash; (/Users/bdm0509/examples) &mdash;
 &mdash; (09:09 $)-&gt; Node NodeFileServer.js
Server running at http://127.0.0.1:1337/
</pre>
<p>And there you have it. While there&#8217;s a lot more to be said about that status line &mdash; and what&#8217;s really going on at port 1337 &mdash; the big news here is that Node is a program that you feed JavaScript. What Node then does with that JavaScript isn&#8217;t worth much ink; to some degree, just accept that what it does, it <em>does</em>. This frees you up to write JavaScript, not worry about learning C. Heck, a big appeal to Node is that you can actually write a server without worrying about C. That&#8217;s the point.</p>
</p>
<h2 id="node-server">Interacting with a &#8220;Node server&#8221;</h2>
</p>
<p>Make sure you still have your <em>NodeFileServer.js</em> code running via Node. Then you can hit your local machine &mdash; on port 1337 &mdash; and see this unremarkable output.</p>
<p class="image-box-580">
<a href="http://s.radar.oreilly.com/2011/06/22/file_server-browser.png"><br />
<img src="http://s.radar.oreilly.com/2011/06/22/file_server-browser-580.png" width="580" border="0" alt="File server browser" style="margin-bottom: 15px" /></a><br />
<a href="http://s.radar.oreilly.com/2011/06/22/file_server-browser.png">Click to enlarge</a></p>
<p>Yes, this is about as mundane as you can get. Well, that is, until you realize that you&#8217;ve actually written a file server in about 20 lines of code. The output you see &mdash; the actual code of the script you wrote &mdash; isn&#8217;t canned in the script itself. It&#8217;s being served from the file system. Throw an image into the same directory, and simply add the name of the image to the end of your URL, like <em>http://localhost:8080/my_image.png</em>:</p>
<p class="image-box-580">
<a href="http://s.radar.oreilly.com/2011/06/22/file_server-image.png"><br />
<img src="http://s.radar.oreilly.com/2011/06/22/file_server-image-580.png" border="0" alt="image example" width="580" /></a></p>
<p>Node happily serves this binary image up. That&#8217;s pretty remarkable, when you again refer to the brevity of the code. On top of that, how hard would it be if you wanted to write <em>your own</em> server code in JavaScript? Not only that, but suppose you wanted to write that code to handle multiple requests? (That&#8217;s a hint; open up four, five, or 10 browsers and hit the server.) The beauty of Node is that you <em>can</em> write entirely simple and mundane JavaScript to get these results.</p>
</p>
<h2 id="primer">A quick line-by-line primer</h2>
</p>
<p>There&#8217;s a lot more to talk about around Node than in the actual code that runs a server. Still, it&#8217;s worth taking a blisteringly fast cruise through <em>NodeFileServer.js</em> before moving on. Take another look at the code:</p>
<pre>
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
</pre>
<p>First, you have a call to a function called <span class="code">require()</span>. The use of <span class="code">require()</span> has been a long-standing request by programmers. You can actually find this mentioned in some of <a href="http://wiki.commonjs.org/wiki/Modules/1.1">the discussions on JavaScript modularity</a>, as well as germane to <a href="http://www.commonjs.org/">CommonJS</a>, and a <a href="http://www.davidflanagan.com/2009/11/commonjs-module.html">pretty cool implementation</a> by O&#8217;Reilly author <a href="http://www.davidflanagan.com/">David Flanagan</a> from 2009. In other words, <span class="code">require()</span> may be new to you, but it isn&#8217;t an untested, careless piece of Node code. It&#8217;s core to using modular JavaScript, and something of which Node takes heavy advantage.</p>
<p>Then, the resulting <span class="code">http</span> variable is used to create a server. That server is handed a function block to run when it&#8217;s contacted. This particular function ignores the request completely and just writes out a response, in <span class="code">text/plain</span>, saying simply &#8220;Hello Worldn&#8221;. Pretty straightforward stuff.</p>
<p>In fact, this lays out the standard pattern for Node usage:</p>
<ol>
<li> Define the type of interaction and get a variable for working with that interaction (via <span class="code">require()</span>).</li>
<li> Create a new server (via <span class="code">createServer()</span>).</li>
<li> Hand that server a function for handling requests.
<ul>
<li> The request handling function should include a request &#8230;</li>
<li> &#8230; and a response.</li>
</ul>
</li>
<li> Tell the server to start handling requests on a specific port and IP (via <span class="code">listen</span>).</li>
</ol>
<h2 id="translation">Lost in translation</h2>
</p>
<p>Despite the ease with which you <em>can</em> get a server coded in JavaScript (regardless of whether the actual code-running facility is C or anything else) still begs the question: <em>Should</em> you write a server in JavaScript? To really get a handle on the answer to this question, consider a pretty typical use case.</p>
<h3 id="json">The JSON round trip</h3>
<p>You&#8217;ve got a typical web application, HTML front-end with CSS styling, and JavaScript for the validation and communication with a server. And because you&#8217;re up on the interactive web, you&#8217;re using Ajax and not relying purely on a form&#8217;s POST to get data to and from the server. If this is you, then you&#8217;re probably comfortable with <a href="http://www.json.org/">JSON</a>, too, as that&#8217;s the almost de facto means of sending data across the wire these days.</p>
<p>So you&#8217;ve got an Ajax request that says, for example, &#8220;give me more information about some particular guitar on an online auction site.&#8221; That request gets thrown across the network to a PHP program running on a server somewhere. The PHP server has to send a lot of information back to the JavaScript requestor, and it&#8217;s got to send that information in some format that JavaScript can unpack. So the return information is bundled up into an array, which can then be converted to JSON, sort of like this:</p>
<pre>
$itemGuitar = array(
  'id' =&gt; 'itemGuitar',
  'description' =&gt; 'Pete Townshend once played this guitar while his own axe ' .
                    was in the shop having bits of drumkit removed from it.',
  'price' =&gt; 5695.99,
  'urls' =&gt; array('http://www.thewho.com', 'http://en.wikipedia.com/wiki/Pete_Townshend')
);

$output = json_encode($itemGuitar);
print($output);
</pre>
<p>Back on the client, the JavaScript gets this chunk of information, which has changed slightly because of JSON and transmission. The client basically gets something like this:</p>
<pre>
{
  "id": "itemGuitar",
  "description": "Pete Townshend once played this guitar...",
  "price": 5695.99,
  "urls": ["http://www.thewho.com", "http://en.wikipedia.com/wiki/Pete_Townshend"]
}
</pre>
<p>This is pretty standard fare. Then, it&#8217;s easy to convert this text &#8220;thing&#8221; into an object in JavaScript. You just call <span class="code">eval()</span>, like this:</p>
<pre>
var itemDetails = eval('(' + jsonDataString + ')');
</pre>
<p>The result is a nice JavaScript object with properties that match up to the JSON array-like structure. Of course, since the <span class="code">jsonDataString</span> usually is returned from a server, you&#8217;re more likely to see code like this:</p>
<pre>
var itemDetails = eval('(' + request.responseText + ')');
</pre>
<p>This is the typical JSON round trip. But there are problems here &#8230; big, big problems.</p>
<h3 id="solid-code">Subtlety and nuance destroy solid code</h3>
<p>First, there&#8217;s a major problem in that this sort of code relies heavily on a translator. In this case, the translator is the JSON interpreter and related code, and there are in fact <em>two</em> dependencies: a JSON interpreter for Java in the form of what <span class="code">eval()</span> does with the response text, and the JSON interpreter for PHP. As of PHP 5.2.0, that interpreter is included with PHP, but it&#8217;s still essentially an external dependency, separate from the core of PHP.</p>
<p>Now, this isn&#8217;t a rant about translation itself. There&#8217;s nothing to suggest that there are problems in taking, say, an &#8220;l&#8221; and turning it into an &#8220;i&#8221;, or something that&#8217;s item 1 in an array and reporting it as being item 2 in an array. There&#8217;s a lot of testing that occurs before JSON tools are ever released to ensure that what gets reported is correct, and accurate round tripping from a client to a server and back again are possible. Lots and lots and lots of testing is involved &#8230;</p>
<p>And that is in fact a problem.</p>
<p>The dependency of JavaScript and PHP (and C and Lisp and Clojure and Eiffel and &#8230; well, see the figure below for all the JSON toolkits floating around for a ton of different languages) on a toolkit is a huge issue. In other words, the problem isn&#8217;t the transla<em>tion</em> but the transla<em>tor</em>. While programming languages evolve slowly, the uses to which these languages are applied is growing quickly. The result is that JSON is being put to use in areas of complexity that simply didn&#8217;t exists or went untouched even a few months ago. And with each new iteration &mdash; each new depth of recursion and combination of data types &mdash; it&#8217;s possible that an area is discovered that the translator doesn&#8217;t support.</p>
<p class="image-box-580">
<a href="http://s.radar.oreilly.com/2011/06/22/many-json.png"><br />
<img src="http://s.radar.oreilly.com/2011/06/22/many-json-580.png" width="580" border="0" alt="JSON toolkits" style="margin-bottom: 15px" /><br />A selection of JSON toolkits. <a href="http://s.radar.oreilly.com/2011/06/22/many-json.png">Click to see the full list</a></p>
<p>That&#8217;s not in itself bad. In fact, it argues for the popularity of JSON that it&#8217;s constantly put to new use. But with the &#8220;new&#8221; comes the &#8220;does it support the new?&#8221; So JSON has to evolve from time to time, and that means testing, and retesting, and release on tons of platforms. You, the programmer, may have to rearrange your data; or wait on a release to support your needs; or hack at JSON yourself. Again, many of these are just the so-called costs of programming.</p>
<p>But imagine you could ditch the translation &mdash; and therefore the translator &mdash; altogether. Imagine you could write, not JSON round tripping, but JavaScript end to end.</p>
<p>That&#8217;s the promise of Node. All the text you&#8217;ve just read &mdash; about PHP including JSON in 5.2.0 but not before, about arrays becoming objects, about data being configured in new ways and requiring new things from JSON &mdash; it all goes away when you have JavaScript sending data <em>and</em> receiving and responding to that data.</p>
<h3 id="eval">eval() in JavaScript is (Potentially) the Devil</h3>
<p>As if that&#8217;s not enough reason to look seriously at Node, there&#8217;s the pesky issue of running <span class="code">eval()</span>  on a string. It&#8217;s long been accepted that <span class="code">eval()</span> <a href="http://stackoverflow.com/questions/86513/why-is-using-javascript-eval-function-a-bad-idea">is dangerous stuff</a>. It runs code that you can only see as textual data; it&#8217;s the equivalent of that &#8220;Run Your SQL by typing it in here&#8221; unvalidated text box, open to SQL injection and malicious intent. It&#8217;s quite possible that every time <span class="code">eval()</span> is passed in a string, a puppy somewhere in the Midwest shivers and a mom on the Eastern Seaboard stubs her toe and curses. It&#8217;s that precarious. There&#8217;s plenty to read about online, and it&#8217;s not worth going into in detail here. Just Google <a href="http://www.google.com/#sclient=psy&amp;hl=en&amp;source=hp&amp;q=eval+javascript+evil&amp;aq=f&amp;aqi=g-jl1g-b1&amp;aql=&amp;oq=&amp;pbx=1&amp;bav=on.2,or.r_gc.r_pw.&amp;fp=5304212dfdd8a916&amp;biw=1040&amp;bih=1090">&#8220;eval JavaScript evil&#8221;</a> or <a href="http://www.google.com/#sclient=psy&amp;hl=en&amp;source=hp&amp;q=eval+javascript+injection&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;pbx=1&amp;bav=on.2,or.r_gc.r_pw.&amp;fp=5304212dfdd8a916&amp;biw=1040&amp;bih=1090">&#8220;eval JavaScript injection&#8221;</a> to get a good taste of the issues.</p>
<p>Still, Node without any context doesn&#8217;t allow you to avoid <span class="code">eval()</span>, so there are potentially still shivering puppies out there. However, Node used <em>as it&#8217;s intended</em> absolutely gets you around the typical <span class="code">eval()</span> problems. Node is often called <em>evented JavaScript</em> or <em>evented I/O</em>, and that little word &mdash; &#8220;evented&#8221; &mdash; is hugely important. But to get a hold of what evented really means, and why it gets you out of the dangers of <span class="code">eval()</span>, you&#8217;ve got to understand not just how JSON is typically round tripped in applications, but how the very structure of applications on the web are typically architected.</p>
</p>
<h2 id="big-event-web">Today&#8217;s web is a big-event web</h2>
</p>
<p>Typical web forms are &#8220;big-event&#8221; submitters. In other words, lots of data entry and selection happens &mdash; a user fills out text boxes, selects choices from combo boxes, selects items from a list, and so on &mdash; and then all of that information is submitted to a server. There&#8217;s a single &#8220;big event&#8221; from the programming perspective: the submission of all that form data, usually through a POST. That&#8217;s pretty much how the web operated, pre-Ajax.</p>
<h3 id="data-dump">Sending lots of data at one time</h3>
<p>With Ajax, there is a little more of what&#8217;s called <em>evented</em> programming. There are more events that trigger interaction with the server. The classic case is the entry of a zip code, and then a resulting call to the server to get a city and state. With Ajax and the XmlHttpRequest, tons of data didn&#8217;t have to be gobbed up and thrown to the server all at once. However, that doesn&#8217;t change the reality that the web is still <em>mostly</em> a big-event place. Ajax is used far more often to achieve interesting visuals, do quick validations, and submit forms without leaving a page than it is to create truly evented web pages. So even though a form isn&#8217;t submitting a big gob of information with a POST, an Ajax request is doing the same thing.</p>
<p>Honestly, that&#8217;s only partly the fault of less-than-creative Ajax programmers. Every time you send off a request &mdash; no matter how small &mdash; there&#8217;s a lot of network traffic going on. A server has to respond to that request, usually with a new process in its own thread. So if you really move to an evented model, where you might have 10 or 15 individual micro-requests going from a single page to a server, you&#8217;re going to have 10 or 15 threads (maybe less, depending on how threads are pooled and how quickly they&#8217;re reclaimed on the server) firing up. Now multiply that by 1,000 or 10,000 or 1,000,000 copies of a given page floating around &#8230; and you could have chaos. Network slowdown. System crashes.</p>
<p>The result is that, in most cases, the Web <em>needs</em> to be, at a minimum, a medium-event place. The result of this concession is that server-side programs aren&#8217;t sending back tiny responses to very small and focused requests. They&#8217;re sending back multiple bits of data, and that requires JSON, and then you&#8217;re back to the <span class="code">eval()</span> problem. The problem is <span class="code">eval()</span>, sure, but the problem is also &mdash; from a certain perspective, at least &mdash; the nature of the web and threading and HTTP traffic between a web page and a server-side program responding to that request.</p>
<p>(Some of you more advanced JavaScript folks are screaming at this point, because you know better than to use <span class="code">eval()</span>. Instead, you&#8217;re <a href="http://stackoverflow.com/questions/1843343/json-parse-vs-eval">using something like <span class="code">JSON.parse()</span> instead of <span class="code">eval()</span></a>. And there are also some <a href="http://javascriptweblog.wordpress.com/2010/04/19/how-evil-is-eval/">compelling arguments for careful usage of <span class="code">eval()</span></a>. These are things worth screaming about. Still, just see how many questions there are surrounding <span class="code">eval()</span> on sites like <a href="http://stackoverflow.com/">Stack Overflow</a> and you&#8217;ll realize that most folks don&#8217;t use <span class="code">eval()</span> correctly or safely. It&#8217;s a problem, because there are lots of intermediate programmers who just aren&#8217;t aware of the issues around <span class="code">eval()</span>.)</p>
<h3 id="little-data">Sending a little data at all times</h3>
<p>Node brings a different approach to the party: it seeks to move you and your web applications to an evented model, or if you like, a &#8220;small event&#8221; model. In other words, instead of sending a few requests with lots of data, you should be sending tons of requests, on lots of events, with tiny bits of data, or requests that need a response with only a tiny bit of data. In some cases, you have to almost recall your GUI programming. (All the <a href="http://en.wikipedia.org/wiki/Swing_(Java)">Java Swing</a> folks can finally use their pent-up GUI knowledge.) So a user enters their first and last name, and while they&#8217;re moving to the next box, a request is already requesting validation of just that name against existing names. The same is true for zip codes, and addresses, and phone numbers. There&#8217;s a constant stream of requesting and responding happening, tied to almost every conceivable event on a page.</p>
<p>So what&#8217;s the difference? Why is this possible with Node, and aren&#8217;t the same issues around threading existent here? Well, no, they&#8217;re not. <a href="http://Nodejs.org/">Node&#8217;s own site</a> explains their philosophy the best:</p>
<blockquote><p>Node&#8217;s goal is to provide an easy way to build scalable network programs. In the &#8220;<a href="http://nodejs.org/">hello world</a>&#8221; web server example &#8230; many client connections can be handled concurrently. Node tells the operating system (through epoll, kqueue, /dev/poll, or select) that it should be notified when a new connection is made, and then it goes to sleep. If someone new connects, then it executes the callback. Each connection is only a small heap allocation.</p>
</blockquote>
<p>Node has no blocks, no threads competing for the same resource (Node is happy to just let things happen however they happen), nothing that has to start up upon request. Node just sits around waiting (quite literally; unused Node responders are sleeping). When a request comes in, it&#8217;s handled. This results in very fast code, without uber-programmers writing the server-side behavior.</p>
<h3 id="chaos">Yes, chaos can ensue</h3>
<p>It&#8217;s worth pointing out that this model does allow all the problems that any non-blocking system allows to come into play: one process (not thread) writing to a data store while another one grabs just-invalidated data; intrusions into what amounts to a transaction; and so on. But realize that the majority of event-based programming on a web form is <em>read-only</em>! How often are you actually modifying data in a micro-request? Very rarely. Instead, there&#8217;s a constant validation, data lookup, and querying going on. In these cases, it&#8217;s better to just fire away with the requests. The database itself may add some locking, but in general, good databases will do this much more efficiently than server-side code, anyway; and they&#8217;ll certainly handle things better than an operating system will spin up and down threads for a generic, &#8220;a web response came in&#8221; process.</p>
<p>Additionally, Node does have plans to allow for process forking, and the <a href="http://www.whatwg.org/specs/web-workers/current-work/">HTML5 Web Workers API</a> is the engine that will probably make this feature go. Still, if you move to an evented model for your web application, you&#8217;ll probably run into an issue where you might <em>want</em> threading in less than one out of 100 situations. Still, the changes are best in how you think about your web applications, and how often you send and receive data from a server, rather than in how Node works.</p>
</p>
<h2 id="right-place">In the right place at the right time</h2>
</p>
<p>There&#8217;s another web pattern at work here, and it&#8217;s probably far more important than whether you use Node or not, and how evented your web applications are. It&#8217;s simply this: use different solutions for different problems. Even better, use the right solution for a particular problem, regardless of whether that&#8217;s the solution you&#8217;ve been using for all your other problems.</p>
<h3 id="familiarity">The inertia of familiarity</h3>
<p>There&#8217;s a certain inertia in not just web design, but all of programming. That inertia can be stated axiomatically like this: the more you learn, use, and become good at a certain approach or technique or language, the more likely you are to use that approach/technique/language widely. It&#8217;s one of those principles that sounds good until you dig deeply. Yes, it&#8217;s good to learn a language or toolkit well, and to employ it widely. But this inertia often causes you to use a tool <em>because</em> you know it, rather than because it&#8217;s the <em>right</em> tool.</p>
<p>Look at Ajax, something already discussed. Initially, Ajax provided a solid approach to sending quick requests, without form submissions, to a server. Now it&#8217;s become a drop-in replacement for <em>all</em> form submissions. That&#8217;s taking a technology, learning it, applying it, and then eventually <em>over</em>-applying it. There&#8217;s still a solid place for form submissions &mdash; when a form needs to be submitted! As simple as it sounds, there are tends of thousands of web applications submitting forms with Ajax, just because the lead web developer is up on Ajax.</p>
<p>In the same vein, it&#8217;s possible to get excited about Node &mdash; probably because you buy into all the splendid and wise observations you&#8217;ve been reading &mdash; and then use it everywhere. Suddenly, you&#8217;re replacing all your PHP and Perl back-ends with Node. The result? A mess. In fact, you&#8217;ll be forced to have several web forms do just what Node <em>isn&#8217;t</em> meant for: submit big chunks of data to JavaScript on the server via Node, and force that JavaScript to either send back a chunk of JSON that&#8217;s got to be parsed or <span class="code">eval()</span>ed, or send back a full-blown HTML page or an HTTP redirect.</p>
<p>But that&#8217;s simply not what Node is best at. It&#8217;s great at micro-requests; at evented I/O. Use Node for quick communication between a web page and a server. Use form submissions to send big chunks of data to the server. Use PHP and Perl to do heavy database lifting and generate dynamic HTML pages. Use Node to provide a means for server-side JavaScript to run and handle small requests. Throw in Rails and Spring and servlets and whatever else you need. But make your decisions based upon the problem you&#8217;re solving, rather than what you happen to know best at the time.</p>
<h3 id="simplicity">Node&#8217;s promise of simplicity</h3>
<p>There&#8217;s one last note worth making. When you take this broad approach to programming, you&#8217;ll often find that you&#8217;re not having to go as deeply into each toolkit, API, and framework you use. By using your tools for what they&#8217;re best at, you don&#8217;t need to be able to staple with hammers or measure with drills. Using tools for their intended purpose typically means you use the core capabilities more. So while you&#8217;re creating generalists &mdash; programmers that know lots of things &mdash; you are also reducing the need for specialists &mdash; programmers that know one or two things <em>really, really</em> well. Of course, every pointy-haired boss also realizes that those specialists are <em>really, really</em> expensive and hard to find.</p>
<p>Learning Node might take a little effort, but it&#8217;s going to pay off. Why? Because you&#8217;re afforded solutions to your web application problems that require only JavaScript to solve. That means your existing JavaScript expertise comes into play. And when you do need to use PHP or Perl &mdash; because it&#8217;s the right solution for a particular problem &mdash; you don&#8217;t need a PHP or Perl guru. You need to know the basics, and those needs can be expanded when the problem requires expansion. Stretching comes at the behest of new problems, rather than stretching poor solutions thinly.</p>
<p>Your biggest challenge is the continual move to a web that is made up of smaller pieces, talking more often, and the combination of what can seem like a dizzying array of technologies. However, taking the core features of 100 technologies is always going to serve you better than taking 100% of one technology and trying to solve 100 problems. Node and evented I/O isn&#8217;t a solution to every problem, but it sure is a solution to some important problems.</p>
<hr />
<p><em>OSCON 2011, coming up later this month, will feature an entire day dedicated to Node. <a href="http://www.oscon.com/oscon2011/public/schedule/detail/20334?cmp=il-radar-os11-what-is-node">Learn more about Node Day</a> and  <a href="https://en.oreilly.com/oscon2011/public/regwith/os11rad?cmp=il-radar-os11-what-is-node">save 20% on registration with the codeOS11RAD</a>.</em></p>
<p></p>
<p><strong>Related:</strong></p>
<ul>
<li> <a href="http://radar.oreilly.com/2010/11/new-directions-in-web-architec.html">Node: Up and Running</a> (Book)</li>
<li> <a href="http://radar.oreilly.com/2011/06/node-javascript-success.html">The secrets of Node&#8217;s success</a></li>
<li> <a href="http://radar.oreilly.com/2011/06/time-to-learn-javascript.html">Why a JavaScript hater thinks everyone needs to learn JavaScript in the next year</a></li>
<li> <a href="http://radar.oreilly.com/2011/06/javascript-edges-permanent-james-duncan.html">JavaScript spread to the edges and became permanent in the process</a></li>
<li><a href="http://www.youtube.com/watch?v=OUCHr2H-7_g">What is Node.js and what does it do?</a> (Video)</li>
<li> <a href="http://radar.oreilly.com/2011/07/what-is-html5.html">What is HTML5?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2011/07/what-is-node.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>We are iPad. Resistance is (not) futile</title>
		<link>http://radar.oreilly.com/2010/04/we-are-ipad-resistance-is-not.html</link>
		<comments>http://radar.oreilly.com/2010/04/we-are-ipad-resistance-is-not.html#comments</comments>
		<pubDate>Fri, 09 Apr 2010 13:00:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[maker]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2010/04/we-are-ipad-resistance-is-not.html</guid>
		<description><![CDATA[A lot of people are upset about how closed the iPhone, and now the iPad, are. Cory Doctorow wrote a lengthy piece about <a href="http://www.boingboing.net/2010/04/02/why-i-wont-buy-an-ipad-and-think-you-shouldnt-either.html">the evils of the iPad and its awful closed system.</a>  I agree that Apple has taken far too much away. I agree that it is infantalizing to require us to send in the iPad to get its battery replaced.  But, my gosh, when did developers ever need permission to break things? When did Steve Jobs become not just rule maker, but some sort of deity that actually prevented me from ignoring said rule maker, and doing whatever I could with my device? ]]></description>
				<content:encoded><![CDATA[<p>The rules beg to be broken.</p>
<p>Bear with me; anecdotes are required.</p>
<p><strong>1990:</strong></p>
<p><a href="http://oreilly.com/ipad?cmp=il-radar-ipadhp-weareipad"><img alt="iPad Coverage" src="http://s.radar.oreilly.com/ipad-promo-250.jpg" border="0" width="250" height="190" style="float: right;margin: 0 0 12px 12px" /></a>Twenty years ago, I was 13, and my father was not. He owned a 286, or perhaps a 386; I very much did not. For him, his computer was a functional employee. It did what he told it to do, slightly faster than a mathematical child prodigy, and he cared very little for what that manilla box chose to do when he was not around.</p>
<p>I, on the other hand, was far more interested in how that slab behaved, and the psychosis of that behavior. I wanted inside. And while I was forbidden to play with the computer, I was not forbidden to open an unlocked toolbox, find a Phillips-head screwdriver, and put it to work.</p>
<p>At some point, my unscrewing of the eyeless computer definitely became play for me. I opened the closed system, and have been working in, with, and around computers every since. I was yelled at soundly that evening &#8212; leaving the various parts scattered around the room and then going to a church youth function without reassembling those parts might have contributed to the problem &#8212; but it changed me.</p>
<p>Rules? Sure. I learn best when there are rules, because they beg me to break them and see what happens.</p>
<p><span id="more-39584"></span>
<p><strong>2000:</strong></p>
<p>I was a Java and XML expert, and <a href="http://www.servlets.com/jason/">Jason Hunter</a> was not. He hated <a href="http://www.saxproject.org/">SAX</a> and <a href="http://www.w3.org/DOM/">DOM</a>; I had been teaching them so long that I&#8217;d forgotten I hated them, too.</p>
<p>He didn&#8217;t like the rules. He thought the APIs were stupid. He was right. He convinced me to open the closed system, and <a href="http://jdom.org/index.html">JDOM</a> was born. Nobody liked us in those early days; certainly not the W3C or Sun, who was busily endorsing SAX and DOM in their Java API stack.</p>
<p>Now, JDOM is a core part of a whole lot of Java and XML processing. There are quotes from Sun on the <a href="http://jdom.org/docs/quotes.html">JDOM quotes page</a>.</p>
<p><strong>2010:</strong></p>
<p>A lot of people are upset about how closed the iPhone, and now the iPad, are. Cory Doctorow &#8212; who I usually enjoy &#8212; wrote a lengthy piece about <a href="http://www.boingboing.net/2010/04/02/why-i-wont-buy-an-ipad-and-think-you-shouldnt-either.html">the evils of the iPad and its awful closed system.</a></p>
<p>He says, among other things, this:</p>
<blockquote><p>The model of interaction with the iPad is to be a &#8220;consumer,&#8221; what William Gibson memorably described as &#8220;something the size of a baby hippo, the color of a week-old boiled potato, that lives by itself, in the dark, in a double-wide on the outskirts of Topeka. It&#8217;s covered with eyes and it sweats constantly. The sweat runs into those eyes and makes them sting. It has no mouth &#8230; no genitals, and can only express its mute extremes of murderous rage and infantile desire by changing the channels on a universal remote.&#8221;</p>
<p>The way you improve your iPad isn&#8217;t to figure out how it works and making it better. The way you improve the iPad is to buy iApps. Buying an iPad for your kids isn&#8217;t a means of jump-starting the realization that the world is yours to take apart and reassemble; it&#8217;s a way of telling your offspring that even changing the batteries is something you have to leave to the professionals.</p>
</blockquote>
<p>First, I agree completely with Cory&#8217;s premise. I agree that Apple has taken far too much away. I agree that it is infantalizing to require us to send in the iPad to get its battery replaced. I agree that we should not have the App Store as a great gatekeeper in the <strike>sky</strike> cloud.</p>
<p>But, my gosh, when did developers ever need permission to break things? When did Steve Jobs become not just rule maker, but some sort of deity that actually prevented me from ignoring said rule maker, and doing whatever I could with my device?</p>
<p>Again, from Cory:</p>
<blockquote><p>Then there&#8217;s the device itself: clearly there&#8217;s a lot of thoughtfulness and smarts that went into the design. But there&#8217;s also a palpable contempt for the owner. I believe &#8212; really believe &#8212; in the stirring words of the <a href="http://makezine.com/04/ownyourown/">Maker Manifesto</a>: if you can&#8217;t open it, you don&#8217;t own it. Screws not glue. The original Apple ][+ came with schematics for the circuit boards, and birthed a generation of hardware and software hackers who upended the world for the better. If you wanted your kid to grow up to be a confident, entrepreneurial, and firmly in the camp that believes that you should forever be rearranging the world to make it better, you bought her an Apple ][+. <em>[Note: Link added.]</em></p>
</blockquote>
<p>I&#8217;m sorry, but this is revisionist. While the Apple ][+ might have enabled a generation to follow, the hackers were well alive before they were handed schematics. Case in point, my earlier anecdote: I needed neither permission nor instructions from my father (or IBM) to break into that enticing bland metal case and tear out its guts. I just needed a screwdriver.</p>
<p>In fact, there is a vast difference between an <em>intention</em> for a consumer to not open a device and an <em>inability</em> of that device to be opened. Thankfully, iFixit didn&#8217;t get the memo that Steve would be upset if you broke into the iPad, and <a href="http://www.ifixit.com/Teardown/iPad-Teardown/2183/1">opened it within hours of release</a>.</p>
<p>Then again, perhaps they did get the memo. They just chose to ignore it.</p>
<p>Mike Loukides, a fellow editor and one of the brightest minds at O&#8217;Reilly, said it well (in email):</p>
<blockquote><p>&#8230; the iPad presents a challenge, and that&#8217;s a good thing.  The argument is perverse (closed is good because it invites you to hack it), but I think it&#8217;s valid.</p>
</blockquote>
<p>Yes, it&#8217;s perverse. And I, like Cory, am strongly for Apple getting out of my way. I&#8217;d like things to be more open. I&#8217;d like to have an easier means of sharing my comics, and my books, and my data. (I actually think that is the strongest portion of Cory&#8217;s argument, and one I firmly agree with.)</p>
<p>But, failing Apple&#8217;s permission, I&#8217;m sure there are many, many 13-year olds, unafraid of dad &#8212; or perhaps very afraid, but willing to pay the price &#8212; and they are picking up their screwdrivers.</p>
<p>Resist. Why not? It&#8217;s how creativity is born.</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2010/04/we-are-ipad-resistance-is-not.html/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Is the &quot;e&quot; in ebooks the new blink tag?</title>
		<link>http://radar.oreilly.com/2010/03/is-the-e-in-ebooks-the-new-tag.html</link>
		<comments>http://radar.oreilly.com/2010/03/is-the-e-in-ebooks-the-new-tag.html#comments</comments>
		<pubDate>Tue, 30 Mar 2010 13:12:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[@home]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2010/03/is-the-e-in-ebooks-the-new-tag.html</guid>
		<description><![CDATA[The first group/publisher/company/person who moves away from the ebook and to content -- content that can be delivered to a variety of media, digital and non-digital, with display and style applied separate from and after content creation -- wins.  ]]></description>
				<content:encoded><![CDATA[<p>Do you remember the <a href="http://en.wikipedia.org/wiki/Blink_element">blink</a> tag? My gosh, I do. This was back when we were indiscriminately mixing our content and presentation, our HTML and our CSS, our data and its display. Usually you&#8217;d be graced with this tag in some horrible sort of &#8220;40% off!&#8221; fashion.</p>
<p><span class="mt-enclosure mt-enclosure-image"><a href="http://s.radar.oreilly.com/40p_off.jpg"><img alt="40p_off.jpg" src="http://s.radar.oreilly.com/assets_c/2010/03/40p_off-thumb-486x112.jpg" width="486" height="112" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></a></span></p>
<p>We&#8217;d all grimace at this abuse of the web (and even the most common sense of design). Why? Well, besides the tag itself being obnoxious, this was a classic case of taking your content and manually controlling how that content would look. That little bit of data &#8212; &#8220;40% off&#8221; &#8212; was inexorably and permanently linked with a bit of formatting &#8212; the &lt;blink&gt; tag. </p>
<p>And you all know about this, whether your knowledge is localized to the blink tag, or just produced in a growing separation-of-content model for web design and development. Hardly anyone intentionally and consistently mixes content and presentation in web pages these days. CSS (and <a href="http://sass-lang.com/">SASS</a>, in some circles) simply makes it too easy to keep your style separate from your content.</p>
<p>So here we are in 2010, all design-sophisticates, separating our content from our style. Well, on the web we are. The more I listen and watch and involve myself in ebooks, though, the more I find myself thinking about the blink tag again. And while I think the term &#8220;ebook&#8221; is useful and possibly necessary for intelligent conversation, I just wonder if that little &#8220;e&#8221; in front of &#8220;ebook&#8221; might be on its way toward becoming the new blink tag.</p>
<p><span id="more-39471"></span>
<p>I won&#8217;t draw this out. I&#8217;ll make it simple. Right now, I&#8217;m typing into <a href="http://www.movabletype.org/">Movable Type&#8217;s</a> editor. I&#8217;m typing words, and sentences, and paragraphs. And MT will take those words, sentences, and paragraphs&#8211;my content&#8211;and display it on the Radar blog, formatted, styled, easily consumable by web browsers and RSS readers.</p>
<p><span class="mt-enclosure mt-enclosure-image"><img alt="Typing-in-MT.png" src="http://s.radar.oreilly.com/Typing-in-MT.png" width="550" height="527" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></span></p>
<p>At no point has it even occurred to me, until right now, that I&#8217;m in fact typing e-words or e-sentences. I&#8217;ve not thought about adding an e-carriage return to separate this e-paragraph from the next e-paragraph.</p>
<p>How absurd would that be? Come on. I&#8217;m just typing. I&#8217;m creating content. Plain old raw content. And it just so happens that my content will be delivered in a particular format (a blog). I suppose if O&#8217;Reilly wanted, they could assemble this content with a bunch of other content, and print the sum of all that content into a book. It wouldn&#8217;t be an e-book because its content started out digital. That&#8217;s just as silly as saying that because content first lived in printed form, and then was released digitally, we have a digital print book.</p>
<p><a href="http://www.web2expo.com/webexsf2010"><img src="http://s.radar.oreilly.com/201003221608-tm.jpg" height="200" width="175" border="0" style="float: right;margin: 0 0 12px 12px" alt="Web 2.0 Expo San Francisco" /></a>So why the &#8220;e&#8221; in ebook? Yes, I know there are some naming issues. We have to use language, and we need some means of distinguishing a book bound with glue, printed on paper, from a book that lives purely in the digital realm. I get that with every bit of my editor-laden, grammarian being. Communication requires a distinction.</p>
<p>But I&#8217;m increasingly seeing the ebook treated as more than just a language distinction. I see people creating content with a specific display paradigm in mind. The content assumes a certain width of screen; a certain font size. Images are being inserted not because they belong, but &#8220;because iPhone and iPad users will expect more imagery.&#8221; </p>
<p>Really? </p>
<p>So just because your image is easier to look upon than a blink tag, are we not returning to a very bad time in the history of the Internet?</p>
<p>So let&#8217;s be clear: I&#8217;m saying something that isn&#8217;t overly original, but bears saying (again). The first group/publisher/company/person who moves away from the ebook and to content&#8211;content that can be delivered to a variety of media, digital and non-digital, with display and style applied separate from and after content creation&#8211;wins. They&#8217;ll have lower costs involved with taking content and making it available on multiple platforms. They&#8217;ll have content that can adapt to new formats quickly, because there&#8217;s no &#8220;un-presenting&#8221; content before it can be repurposed for another platform.</p>
<p><span class="mt-enclosure mt-enclosure-image"><a href="http://radar.oreilly.com/assets_c/2010/03/distribute.html"><img src="http://s.radar.oreilly.com/assets_c/2010/03/distribute-thumb-486x318.jpg" width="486" height="318" alt="distribute.jpg" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></a></span></p>
<p>Sure, we&#8217;ll always have ebooks. But can we all hope that this becomes a term based on a distinction in display format and medium, rather than a fundamental distinction between one type of content and another? I&#8217;m really not up for another blink tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2010/03/is-the-e-in-ebooks-the-new-tag.html/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Where&apos;s the continuity?</title>
		<link>http://radar.oreilly.com/2009/08/wheres-the-continuity.html</link>
		<comments>http://radar.oreilly.com/2009/08/wheres-the-continuity.html#comments</comments>
		<pubDate>Tue, 18 Aug 2009 20:14:10 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[communication]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/08/wheres-the-continuity.html</guid>
		<description><![CDATA[As seen in comic books, continuity has long been considered a function of good fiction. Here&apos;s a simple question: in your reading, your writing, your speaking, your programming, what are you doing to create and absorb context and continuity? I believe there are ways to achieve this in almost every field, and I believe this is an important part of what sets the elite apart from the non-elite in terms of communication. ]]></description>
				<content:encoded><![CDATA[<p><span class="mt-enclosure mt-enclosure-image"><img alt="comics.jpg" src="http://s.radar.oreilly.com/brett/comics.jpg" width="640" height="425" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></span></p>
<p>I&#8217;ve recently resumed a childhood love affair with comics. In particular, I&#8217;m a fan of the Uncanny X-Men. While they&#8217;re not as edgy as the Dark Knight, and not as hip as a Dark Horse mini-series, they&#8217;re what got me started on comics, and what I continually go back to. (Besides that, they&#8217;re much more interesting and generally less sucky than the movies and cartoons of the same name.)</p>
<p>Of course, it&#8217;s been a while, so I hopped over to <a href="http://www.uncannyxmen.net/">UncannyXMen.net</a> to figure out what&#8217;s been going on. They have a nice primer to help you figure out how all the various titles intersect, which is non-trivial to keep track of in the X-Universe.</p>
<p>Interestingly, I ran across this:</p>
<p><span class="mt-enclosure mt-enclosure-image"><img alt="alphaflight1.jpg" src="http://s.radar.oreilly.com/brett/alphaflight1.jpg" width="600" height="308" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></span></p>
<p>This struck me: <a href="http://en.wikipedia.org/wiki/Continuity_%28fiction%29">continuity</a>. Readers loved the continuity of the story.</p>
<p>While it&#8217;s easy to chalk this up as a function of good fiction, I don&#8217;t think it&#8217;s that easy. Putting aside issues of story, I&#8217;m struck by how much looking back and forth I tend to do in reading a comic. I&#8217;m scanning a bit ahead, and reflecting back on what I just read and saw, even while reading the current panel. I&#8217;ve got this constant sense of context; I have a continuity in which what I&#8217;m learning (about a comic book character, about a love interest, about an island that&#8217;s about to be submerged by supersonic waves triggering earthquakes along fault lines, etc.) fits.</p>
<p>So why would we simply accept that in non-fiction&#8211;especially projects and products that purport to actually teach something&#8211;we can&#8217;t have continuity?</p>
<p>In many ways, this is the genius of visual series like <a href="http://www.headfirstlabs.com">Head First</a>, and to a lesser degree in this specific case, the <a href="http://missingmanuals.com/">Missing Manuals</a>. I&#8217;d also argue that this visual format does wonders for the <a href="http://oreilly.com/catalog/9780596802813/">Twitter Book</a> and our new <a href="http://iphoneapps.oreilly.com/">Best iPhone Apps</a> book and site. Without having to re-read a page or flip ahead, you have a sense of visual context. You have a continuity that can be absorbed in a glance, even if you&#8217;re ready body text at the top of a right-hand page.</p>
<p>I could go on and on, but let&#8217;s stop the exposition. Here&#8217;s a simple question: in your reading, your writing, your speaking, your programming, what are you doing to create and absorb context and continuity? I believe there are ways to achieve this in almost every field, and I believe this is an important part of what sets the elite apart from the&#8230; well&#8230; non-elite, in terms of communication.</p>
<p>Where&#8217;s your continuity?</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/08/wheres-the-continuity.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Where are the learners?</title>
		<link>http://radar.oreilly.com/2009/06/where-are-the-learners.html</link>
		<comments>http://radar.oreilly.com/2009/06/where-are-the-learners.html#comments</comments>
		<pubDate>Mon, 22 Jun 2009 20:51:16 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/06/where-are-the-learners.html</guid>
		<description><![CDATA[I tend to browse around Flickr a lot, and came across this image of an empty classroom. So what&apos;s missing here? Well, it would seem obvious... except to many technical book authors. See, for most folks, the obvious answer here is, &#34;There are no students!&#34;  But for the average technical book author -- and to be clear, I&apos;m one of that crowd, so I&apos;m speaking personally and from experience -- we would all, loudly, cry out, &#34;There&apos;s no teacher!&#34; What a fundamental disconnect. ]]></description>
				<content:encoded><![CDATA[<p>I tend to browse around Flickr a lot, and came across this image:</p>
<p><span class="mt-enclosure mt-enclosure-image"><img alt="Empty classroom" src="http://s.radar.oreilly.com/classroom.jpg" width="493" height="327" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></span></p>
<p>So what&#8217;s missing here? Well, it would seem obvious&#8230; except to many technical book authors. See, for most folks, the obvious answer here is, &#8220;There are no students!&#8221;</p>
<p>But for the average technical book author &#8212; and to be clear, I&#8217;m one of that crowd, so I&#8217;m speaking personally and from experience &#8212; we would all, loudly, cry out, &#8220;There&#8217;s no teacher!&#8221;</p>
<p>What a fundamental disconnect.</p>
<p>See, those of us who write do that writing alone (or, in some cases, relatively alone. That&#8217;s author-speak for, &#8220;at my local Starbucks with earphones&#8221;). And yet, we&#8217;ll quickly call ourselves &#8220;teachers.&#8221; But what other type of teacher functions without a group of people in front of them, or at least in mind?</p>
<p>Can you imagine a new math teacher walking into a classroom, and gaping at all the kids seated in the room? &#8220;What are all these kids doing in here?&#8221; We&#8217;d very politely usher that teacher back out into unemployment (or perhaps into further training).</p>
<p>Take a short step away from the empty classroom, and consider the dying technical book market. Yes, it&#8217;s dying. Sales are plummeting for traditional technical books. We&#8217;re having to examine other markets, other formats, other approaches&#8230;</p>
<p>And we&#8217;re back to the empty classroom. Right? Because we&#8217;re building screencasts with an anonymous teacher speaking into a microphone in an empty room. Or we&#8217;re writing iPhone apps that are beautiful&#8230; and do little more than highlight the teacher&#8217;s knowledge.</p>
<p>But what if&#8230; what if we looked at that picture above, and realized that what&#8217;s missing is the <em>student</em>. Better, the <em>learner</em>.</p>
<p>Socrates suggested that learning is remembering (I&#8217;m simplifying, I know, but I&#8217;ve already written longer than I should have). And the beautiful part of his picture of learning was suggesting that he was less a teacher than a midwife. He basically didn&#8217;t teach; he instead aided the learner in learning. He was a facilitator, little more.</p>
<p>So one of the things you&#8217;re going to see over these next few weeks &#8212; from me and from O&#8217;Reilly &#8212; is a renewed focus on the learner. We&#8217;re going to write and ask questions about how to facilitate, rather than lecture. We&#8217;re going to push out some new and engaging products and ideas (some for-pay, some for-free), and we&#8217;re going to put the focus on the learner.</p>
<p>I hate writing a declaratory piece like this, because it doesn&#8217;t encourage interaction as much as I&#8217;d prefer. In a sense, I&#8217;ve broken my own rules, and become lecturer instead of facilitator. I haven&#8217;t been a good midwife. I&#8217;m hoping you see that I&#8217;m trying to do a little stage-setting, for a lot of facilitation.</p>
<p>Maybe you&#8217;ve got comments, ideas, and thoughts. How do you do this? How do you keep your focus off your own &#8220;brilliance&#8221; and on your learner&#8217;s needs? What are you doing to keep the focus on where it belongs?</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/06/where-are-the-learners.html/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>When do your beliefs become knowledge?</title>
		<link>http://radar.oreilly.com/2009/06/when-do-your-beliefs-become-kn.html</link>
		<comments>http://radar.oreilly.com/2009/06/when-do-your-beliefs-become-kn.html#comments</comments>
		<pubDate>Mon, 08 Jun 2009 18:29:10 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/06/when-do-your-beliefs-become-kn.html</guid>
		<description><![CDATA[I&apos;ve been reading a lot of philosophy lately -- Kierkegaard and Dawkins, Lewis, Hume, Calvin and Augustine, you name it -- for a class I&apos;m taking, as well as for my own enjoyment. One of the interesting things about philosophy is that it&apos;s a discipline that takes the understanding of understanding seriously. As a teacher, that&apos;s fascinating to me; has education -- specifically, the way we in 2009 are trying to educate -- really examined what knowledge is? Have educational systems considered what the wealth of literature says about knowledge, and responded to it responsibly? ]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been reading a lot of philosophy lately &#8212; Kierkegaard and Dawkins, Lewis, Hume, Calvin and Augustine, you name it &#8212; for a class I&#8217;m taking, as well as for my own enjoyment. One of the interesting things about philosophy is that it&#8217;s a discipline that takes the understanding of understanding seriously. As a teacher, that&#8217;s fascinating to me; has education &#8212; specifically, the way we in 2009 are trying to educate &#8212; really examined what knowledge is? Have educational systems considered what the wealth of literature says about knowledge, and responded to it responsibly?</p>
<p>[A few important insertions: I'm not supposing that to respond to philosophical ideas about knowledge, education needs to change. I am suggesting, though, that a responsible response entails understanding the arguments, and either adhering to them, or forming a sound counter-argument to explain abandoning them.]</p>
<p>Two theses in particular caught my attention. First, Thomas Reid makes this astounding statement (cited from <em>Thomas Reid&#8217;s Inquiry and Essays</em> (1975), p. 275):</p>
<blockquote><p>Another first principle is&#8211;That the natural faculties, by which we distinguish truth from error, are not fallacious.</p></blockquote>
<p>What does this say? It says that our natural senses don&#8217;t tend to fail us. Now, I know, many of you are freaking out over this quote, especially in light of particle physics or molecular biology. And we can argue that over a good cup of coffee. But I will suggest that Reid is right in the macro-world. </p>
<p><span class="mt-enclosure mt-enclosure-image"><a href="http://s.radar.oreilly.com/falling-piano.jpg"><img alt="falling-piano.jpg" src="http://s.radar.oreilly.com/assets_c/2009/06/falling-piano-thumb-486x427.jpg" width="486" height="427" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></a></span></p>
<p>I see a piano falling, I rightly assume several things:</p>
<p>1. It is indeed falling, and I am not instead rushing up toward it.</p>
<p>2. That piano is dangerous to be under, given that it&#8217;s falling.</p>
<p>There are plenty of other observations, but you get the idea.</p>
<p>So why does this matter? Well, how much do we allow the learner&#8217;s senses (and by senses, I don&#8217;t mean &#8220;ears listening to 90 minutes of lecture&#8221;) engage in a typical learning environment? How much do we allow the natural faculties to assert themselves, create knowledge, and then refine and provide context for the knowledge already gained?</p>
<p>I think it&#8217;s an important question. I think Dan Meyer is a master at this (<a href="http://blog.mrmeyer.com/">check out his blog</a> for some amazing examples of using pictures to stimulate learning). How are you doing this? What effect on education would an increased (as in, significantly more than you&#8217;re currently doing) amount of sensory learning create?</p>
<p>Let me know what you think. Oh, and as for my other philosophical quote that I think is important? More on that later this week&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/06/when-do-your-beliefs-become-kn.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Your brain really is forgetting&#8230; a LOT</title>
		<link>http://radar.oreilly.com/2009/04/your-brain-is-forgetting.html</link>
		<comments>http://radar.oreilly.com/2009/04/your-brain-is-forgetting.html#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:00:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[brain]]></category>
		<category><![CDATA[head first]]></category>
		<category><![CDATA[learning theory]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/04/your-brain-is-forgetting.html</guid>
		<description><![CDATA[I'm currently reading <a href="http://www.amazon.com/Welcome-Your-Brain-Puzzles-Everyday/dp/1596915234/newinstance-20"><em>Welcome to Your Brain: Why You Lose Your Car Keys but Never Forget How to Drive and Other Puzzles of Everyday Life</em></a> by Dr. Sandra Aamodt and Dr. Sam Wang. The enormity of the title notwithstanding, I'm enjoying the book, and ran across this rather amazing quotation:

<blockquote>There is good evidence that we "erase" and "rewrite" our memories every time we call them, suggesting that if it were ever possible to erase specific content, playing it back first might be an essential component.</blockquote> ]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m currently reading <a href="http://www.amazon.com/Welcome-Your-Brain-Puzzles-Everyday/dp/1596915234/newinstance-20"><em>Welcome to Your Brain: Why You Lose Your Car Keys but Never Forget How to Drive and Other Puzzles of Everyday Life</em></a> by Dr. Sandra Aamodt and Dr. Sam Wang. The enormity of the title notwithstanding, I&#8217;m enjoying the book, and ran across this rather amazing quotation:</p>
<blockquote><p>There is good evidence that we &#8220;erase&#8221; and &#8220;rewrite&#8221; our memories every time we call them, suggesting that if it were ever possible to erase specific content, playing it back first might be an essential component.</p></blockquote>
<p>This is a staggering statement. Consider the implications: when you recall a memory, you are capable of &#8211; and prone to &#8211; rewriting that memory in some form. I find this particularly fascinating in terms of teaching in a <a href="http://en.wikipedia.org/wiki/Spiral_approach">spiral method</a>, something I continue to find effective and even critical in highly technical topics.</p>
<p>Take memory management in any programming language. It&#8217;s simply foolish to unload the truck on an unsuspecting learner, dumping out everything there is to know about memory management at one time, in one place, with little or no functional motivation. The better approach is to incrementally teach the topic, adding additional resolution, detail, and expansion only when new functionality is needed or additional understanding is required. In this way, you&#8217;re catering to the learner: each piece of information you&#8217;re unpacking is motivated by a need in that learner. This results in greater internalization of the information, and less information is categorized as &#8220;I don&#8217;t really need this. I&#8217;ll dump this.&#8221;</p>
<p>But with the quote by Aamodt and Wang, there&#8217;s another component at work here: earlier memories are potentially being rewritten as new learning takes place. This is intuitive, even: consider how often we mix up events that are very similar, but not the same. Have you eaten at Chuy&#8217;s 10 times in the last month (I&#8217;m about there)? If so, I&#8217;d suspect you&#8217;ll have a hard time distinguishing at which instance in 10 a certain conversation happened, especially without other mitigating details (a really close friend attended only one meal, or something particularly disastrous happened at another). Is it possible that the brain is trying to shove these similar events into one giant event, because we&#8217;re recalling an earlier (similar) event, replaying it, and rewriting it with the new one?</p>
<p>What this seems to suggest &#8212; and I grant that there&#8217;s a lot of theorizing and speculation happening, but what else is Radar good for if not some provocative thought &#8212; is that we must be <em>extremely</em> careful with context. When you recall an earlier mental model of something, and then augment that model, you may be rewriting the earlier model. In other words, you&#8217;re not just adding to an in-place model, but in fact replacing an earlier model with a newer, expanded one. So what are you doing to ensure the foundational models stay intact? Are you repeating the earlier model, and adding resolution? Or are you just writing about the &#8220;new stuff&#8221; without regard for the existing material?</p>
<p>I think most textbooks and technical books continue to heap on, assuming that pre-existing models remain in place. Foundational concepts never die, these books would assert (if not implicitly, then by the manner in which they teach). But perhaps those concepts do die! Perhaps this is why you may be adept at releasing memory or allocating memory, but would flail about helplessly at explaining what&#8217;s really going on. Is it possible that your original mental model has been overwritten, or even functionally replaced?</p>
<p>It&#8217;s an interesting thought. Context becomes critical, not just as a reminder of pre-existing material, but actually to ensure that pre-existing material is not lost altogether.</p>
<p>C&#8217;mon teachers, you must have thoughts on this&#8230; let&#8217;s hear them.</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/04/your-brain-is-forgetting.html/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Ask&#8230; no, wait&#8230; TELL Tim</title>
		<link>http://radar.oreilly.com/2009/02/ask-no-wait-tell-tim.html</link>
		<comments>http://radar.oreilly.com/2009/02/ask-no-wait-tell-tim.html#comments</comments>
		<pubDate>Wed, 11 Feb 2009 02:35:09 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Edu 2.0]]></category>
		<category><![CDATA[brain]]></category>
		<category><![CDATA[humans]]></category>
		<category><![CDATA[ket]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[ski]]></category>
		<category><![CDATA[Tim O'Reilly]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/02/ask-no-wait-tell-tim.html</guid>
		<description><![CDATA[A few weeks ago, I was chatting with Tim. He mentioned that he&apos;d recently taken his first ride on a Jet Ski. Several torturous minutes later, he got off, still alive and capable of detecting faint signals. But his back was suffering... badly.  ]]></description>
				<content:encoded><![CDATA[<p><span class="mt-enclosure mt-enclosure-image"><a href="http://radar.oreilly.com/assets_c/2009/02/tim-jetski.html"><img src="http://s.radar.oreilly.com/assets_c/2009/02/tim-jetski-thumb-486x325.jpg" width="486" height="325" alt="tim-jetski.jpg" class="mt-image-center" style="text-align: center;margin: 0 auto 20px" /></a></span></p>
<p>Yes, there he is&#8230; our glorious thought-leader, riding a jet ski. But Tim needs your help&#8230; seriously. Here&#8217;s the problem:</p>
<p>A few weeks ago, I was chatting with Tim. He mentioned that he&#8217;d recently taken his first ride on a Jet Ski. Several torturous minutes later, he got off, still alive and capable of detecting faint signals. But his back was suffering&#8230; badly. </p>
<p>Tim, as Tim is prone to do, let the ski rental place know of his pains. The instructor/rental guy looked at Tim, and simply said, &#8220;Oh. You need to lean forward.&#8221;</p>
<p>At this point in our conversation, Tim rolled his eyes, gave a half-wave of his hand, and said, &#8220;Oh, thanks. That would have been nice to know <em>before</em> I got on the ski.&#8221; Obviously, if the instructor had told Tim to lean forward before he took on the Old Man of the Sea, Tim&#8217;s back would have been saved a lot of hardship.</p>
<p>Or would it?</p>
<p>Along with all the other instruction Tim would have received, he&#8217;d have been told, &#8220;Oh, and be sure and lean forward.&#8221; Would this have stuck with Tim? Would it have been held up in his brain as important as, say, &#8220;Keep a tight grip on the handlebars?&#8221; Would it have competed with, &#8220;Look here&#8230; this is the ignition key. Turn it to start, turn it again to stop.&#8221;</p>
<p>Would simply telling Tim ahead of time to lean forward been enough to save Tim&#8217;s back?</p>
<p>Better yet, how would <strong><em>you</em></strong> have prevented Tim&#8217;s back pain? Here&#8217;s the question, broken down for easy answering&#8230;</p>
<p>1. WHEN would you have told Tim, &#8220;Lean forward?&#8221;<br />
2. HOW would you have told Tim?<br />
3. Free response: what else would you have done/not done to ensure Tim got off the jet ski happy, healthy, and not hurting?</p>
<p>Come on&#8230; Tim&#8217;s back is counting on you figuring out how humans learn&#8230; how best to communicate&#8230; and what our brain does with information that is important, but maybe non-obvious in application or significance.</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/02/ask-no-wait-tell-tim.html/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Our brains are sort of&#8230; well&#8230; stupid</title>
		<link>http://radar.oreilly.com/2009/02/our-brains-are-sort-of-well-st.html</link>
		<comments>http://radar.oreilly.com/2009/02/our-brains-are-sort-of-well-st.html#comments</comments>
		<pubDate>Mon, 02 Feb 2009 21:26:00 +0000</pubDate>
		<dc:creator>Brett McLaughlin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.oreilly.com/radar/2009/02/our-brains-are-sort-of-well-st.html</guid>
		<description><![CDATA[ I&apos;ve long heard people complain about how commercials represent the basest forms of humanity. Yesterday, I was reminded of this again, as Twitter was all ablaze with people in outrage over the latest GoDaddy.com commercial run during the Super Bowl. All of this tends to make me roll my eyes a bit, and go, &#34;Well, duh... of course commercials... ]]></description>
				<content:encoded><![CDATA[</p>
<p>I&#8217;ve long heard people complain about how commercials represent the basest forms of humanity. Yesterday, I was reminded of this again, as Twitter was all ablaze with people in outrage over the latest GoDaddy.com commercial run during the Super Bowl.</p>
<p>All of this tends to make me roll my eyes a bit, and go, &#8220;Well, duh&#8230; <em>of course</em> commercials represent the basest forms of humanity. That&#8217;s why they <em>work</em>!&#8221;</p>
<p>Science has long told us that the brain is largely indiscriminate in terms of forming and retaining information (what we tend to simply call &#8220;memory.&#8221;) For instance, if you like and remember the song that played when you proposed to your wife, you&#8217;ll also tend to remember where you were when you heard the song, what the weather was if you were outdoors, details about what your intended was wearing, maybe even what you ate. That&#8217;s because along with the song itself, your brain carried along all the accompanying context.</p>
<p>The thing is, the brain&#8217;s not really that smart. It doesn&#8217;t realize that the two eggs on your plate in the diner really aren&#8217;t as important as the beautiful girl sitting across from you when you heard that new Norah Jones tune that made her go wild and accept your marriage proposal. In theory, those eggs don&#8217;t matter&#8230; nor does the awful plaid shirt you&#8217;d spilled coffee on. But the brain can&#8217;t discriminate. Instead, it just throws everything into &#8220;memory.&#8221;</p>
<p>Super Bowl ads prove this, once and for all. With ad revenue topping <a href="http://www.adweek.com/aw/content_display/news/media/e3if2f60011563fe80feb040ffcc8a27800">206 million bucks</a> (in a recession!), we were hit with ad after ad, all having next to nothing to do with the actual products in question. That&#8217;s because, well, the ad guys are smart. They payed attention to all the available data, which essentially says it&#8217;s better to trick the brain than to appeal to it rationally.</p>
<p>What works better? Slapping a logo acr<a href="http://www.youtube.com/watch?v=78xrL1TQWNU">oss a stretched t-shirt</a>, curving around some surgically enhanced porn star&#8217;s chest, or lauding the wonderful features of hosting at GoDaddy.com? Getting everyone to laugh at the<a href="http://www.youtube.com/watch?v=AhqPl1IKVo4"> fire-breathing/belching dude on a date</a>, or trying to convince the world that the Budweiser hops are better than the Michelob hops?</p>
<p>It&#8217;s a trick. And, once again&#8230; duh!</p>
<p>So here&#8217;s your &#8220;the brain is stupid&#8221; exercise for today. Call it a little reverse engineering.</p>
<p>1. What Super Bowl commercial from this year do you best remember?*<br />
2. What product was being advertised?<br />
3. What Super Bowl commercial from <em>last</em> year do you best remember?<br />
4. What product was being advertised?<br />
5. What Super Bowl commercial do you best remember from <em>any</em> year?<br />
6. What product was being advertised?</p>
<p><em>* Note the question: &#8220;best remember&#8221; as opposed to &#8220;like the best.&#8221; This becomes self-evident as you think back a few years. We remember things we don&#8217;t like in many cases.</em></p>
<p>I&#8217;ll bet good money that you&#8217;ll easily recall the answers to (1), (3), and (5), and that the products attached to each answer come pretty quickly after. Only in the poorest ad placement situations do the product lines not get carried along by our brains in the &#8220;making memory&#8221; process, due to our brain being indiscriminate about what is carried along by a memory.</p>
<p>Last question, and this is the important one:</p>
<p><em>Why did these commercial stick out? What made them &#8220;memorable?&#8221;<br />
</em></p>
<p>More good money says the commercials you remember have no correlation to products that are important to you, except by dumb luck. You&#8217;re reacting to the commercial, which in most cases has almost no relation at all to the product.</p>
<p>Let me re-ask the question like this: taking the three commercials you came up with above, what&#8217;s common? What do you think grabbed your brain by the throat (yes, the metaphor is breaking down. Just roll with me, here) and said, &#8220;Remember me!&#8221;?</p>
<p>How would you make a good Super Bowl commercial?</p>
]]></content:encoded>
			<wfw:commentRss>http://radar.oreilly.com/2009/02/our-brains-are-sort-of-well-st.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
