<?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>glyphobet • глыфобет • γλυφοβετ &#187; TNBT</title>
	<atom:link href="http://glyphobet.net/blog/tag/tnbt/feed" rel="self" type="application/rss+xml" />
	<link>http://glyphobet.net/blog</link>
	<description>musings over a tuna fish sandwich</description>
	<lastBuildDate>Wed, 21 Jul 2010 23:53:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The next big thing, part 3: Taking the relational out of relational databases</title>
		<link>http://glyphobet.net/blog/essay/397</link>
		<comments>http://glyphobet.net/blog/essay/397#comments</comments>
		<pubDate>Mon, 06 Apr 2009 17:45:47 +0000</pubDate>
		<dc:creator>glyphobet</dc:creator>
				<category><![CDATA[essay]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[graph databases]]></category>
		<category><![CDATA[model-view-controller]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[relational databases]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[TNBT]]></category>

		<guid isPermaLink="false">http://glyphobet.net/blog/?p=397</guid>
		<description><![CDATA[Part of an ongoing series.
The relational database is an extremely powerful tool. But sometimes data isn&#8217;t very relational, and sometimes transactional, relational, integrity is not as important as it is for, say, a bank. This is one reason why so many sites can get away with mySQL backed by myISAM tables &#8212; they&#8217;re fine if [...]]]></description>
			<content:encoded><![CDATA[<p><em>Part of <a href="http://glyphobet.net/blog/tag/tnbt">an ongoing series</a>.</em></p>
<p>The relational database is an extremely powerful tool. But sometimes data isn&#8217;t very relational, and sometimes transactional, relational, integrity is not as important as it is for, say, a bank. This is one reason why so many sites can get away with mySQL backed by myISAM tables &#8212; they&#8217;re fine if you&#8217;re read-heavy and data integrity is not mission-critical.</p>
<p><a title="Amazon cat eats Google's dog food." href="http://aws.amazon.com/simpledb/">Some</a> <a title="It's not a big couch." href="http://couchdb.apache.org/">new</a> <a title="Impossible to spell." href="http://sitepen.com/labs/persevere.php">projects</a> <a title="This article is kinda shite, but it has good links." href="http://www.infoworld.com/article/09/03/24/12TC-databases_1.html">have sprung up</a> which provide key-value stores or simpler kinds of databases without all the overhead and inflexibility of a relational database.</p>
<p>On the other hand, sometimes data is way more interrelated than a traditional relational database is prepared to handle. Sometimes different kinds of items (i.e. rows) in a database can be related to many other kinds of items in that database, and sometimes end users can create not just new items or new relationships, but new <em>kinds</em> of relationships between items. This type of database is called a graph database, and there are also projects pushing the boundaries of relational in this completely opposite direction.</p>
<p>Pretty much everywhere I interviewed back in February 2008 was either <a title="It's not sublimation. " href="http://www.freebase.com/">building their own graph database</a>, working on <a title="At least it's not named after a serial killer." href="http://www.mulgara.org/">an existing one</a>, or repurposing a relational database (or, in one case, <a title="Can't people code in something other than Java for once?" href="http://lucene.apache.org/">a search backend</a>), to kinda, sorta behave like one. The w3c, not one to be left behind when there&#8217;s a specification to be written, is even working on <a title="Leave it to the w3c to pick a name that *nobody* will be able to spell." href="http://www.w3.org/TR/rdf-sparql-query/">a SQL-inspired query language</a> intended to search them<sup>1</sup>.</p>
<p>Most applications have some combination of totally un-relational data that can go in a key-value store, some strictly relational data that belongs in a SQL database, and some flexible, highly relational data that belongs in a graph database.</p>
<p>What will happen when these alternative databases start giving traditional relational databases a run for their money? Well, sharding, caching, and normalization all start to sound a lot more complex when the data is in a few different <em>kinds</em> of databases &#8212; but then again, maybe optimization won&#8217;t be as necessary if a single SQL database isn&#8217;t doing all the heavy lifting. <a title="See second round" href="http://www.b-list.org/weblog/2009/mar/28/pycon-orm-panel/">Object-relational mappers</a> (and the <a title="It's not a big truck, it's a series of Pylons." href="http://turbogears.org/">web</a> <a title="It's not a big Lon, it's a series of Py." href="http://pylonshq.com/">frameworks</a> that use them) might need to talk to, and abstract away from, different kinds of databases<sup>2</sup>.</p>
<p>And the different types of data won&#8217;t always be easily separated along table boundaries. Maybe these different types of databases will talk to each other, or maybe they will mature into über-databases that understand lots of different types of data relationships.</p>
<p>But the monolithic, strictly relational, master SQL database is eventually going to go the way of <a title="Series of tubes series of tubes!" href="http://en.wikipedia.org/wiki/COBOL">Cobol</a><sup>3</sup>.</p>
<ol class="footnotes"><li id="footnote_0_397" class="footnote">Of course, if it&#8217;s anything like <a title="Xtremely Stupid Language for Templating" href="http://www.w3.org/TR/xslt">other</a> <a title="Completely Stupid Stylesheets" href="http://www.w3.org/TR/CSS/">technologies</a> designed by the w3c, it&#8217;s a steaming pile.</li><li id="footnote_1_397" class="footnote"><a title="SQL Alchemy" href="http://www.sqlalchemy.org/">Some</a> can already handle talking to multiple SQL databases, and of course there&#8217;s <a title="Should be called N-phase commit" href="http://en.wikipedia.org/wiki/Two-phase_commit_protocol">two-phase commit</a>.</li><li id="footnote_2_397" class="footnote">Or <a title="I.e. nuked. " href="http://en.wikipedia.org/wiki/Kobol">Kobol</a>.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://glyphobet.net/blog/essay/397/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The next big thing, part 2: Taking the web out of web applications</title>
		<link>http://glyphobet.net/blog/essay/352</link>
		<comments>http://glyphobet.net/blog/essay/352#comments</comments>
		<pubDate>Mon, 30 Mar 2009 16:11:23 +0000</pubDate>
		<dc:creator>glyphobet</dc:creator>
				<category><![CDATA[essay]]></category>
		<category><![CDATA[HTML templating]]></category>
		<category><![CDATA[model-view-controller]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[TNBT]]></category>

		<guid isPermaLink="false">http://glyphobet.net/blog/?p=352</guid>
		<description><![CDATA[Part of an ongoing series.
A web application is just a stateless1 application that responds to various requests by performing actions and providing resources. There&#8217;s no fundamental reason an application must only communicate over HTTP. Web applications are going to start adding alternative methods of interaction, and I think the first common one will be email.
Perhaps [...]]]></description>
			<content:encoded><![CDATA[<p><em>Part of <a href="http://glyphobet.net/blog/tag/tnbt">an ongoing series</a>.</em></p>
<p>A web application is just a stateless<sup>1</sup> application that responds to various requests by performing actions and providing resources. There&#8217;s no fundamental reason an application must <em>only </em>communicate over HTTP. Web applications are going to start adding alternative methods of interaction, and I think the first common one will be email.</p>
<p>Perhaps an example will best illustrate this:</p>
<p>Like many web forums, posts to <a title="Not a big truck." href="http://mosuki.com/">Mosuki</a>&#8217;s discussion forums get mailed out in email. But, unlike any other web forums I know of, <a title="It's a series of tubes." href="http://blog.mosuki.com/44/mosuki-august-update-email-replies-and-scenes">they also behave like mailing lists</a>. All the emails have a reply-to header with an email address that identifies the message, the recipient, and the action to be taken if that email address is used. In this case, the contents of a reply email are posted to the forum exactly as if a reply had been posted via the website.</p>
<p>In other words, the action &#8220;post a message&#8221; can be accessed via a web page and a browser or via a reply-to header and your mail client.</p>
<p>There are other examples of this separation between input/output channels and the application logic. The most obvious is <a title="WHOA do you really think I'm going to link to Twitter? Think again.">Twitter</a>, which of course can be interacted with via HTTP <em>or</em> SMS<sup>2</sup>. And the <a title="ZSFA FTW!" href="http://zedshaw.com/blog/2009-03-18.html">Son of Sam</a> project intends to let you &#8220;use modern concepts like handlers, requests, responses, state machines&#8221; to interact with email.</p>
<p>Confirm a Facebook friend request, RSVP to an Evite, revert a Wikipedia edit, or reassign a bug report, just by replying to an email or sending an SMS.</p>
<p>There are a number of technical issues inherent a system like this.  An application&#8217;s framework has to handle multiple input channels, and massage email bodies, HTTP requests, and other input into a least common denominator &#8220;request.&#8221; Authenticating a user via email, an intrinsically forgeable medium, and protecting against spam, are non-trivial challenges. And a suite of templates suddenly gets a lot more complex when it has to provide views for multiple types of interfaces<sup>3</sup> .</p>
<p>This blurring of the line between email, HTTP, SMS, and other communications is not new, strictly speaking. But I think it will become commonplace and even expected. Rather than writing a modern (MVC, stateless, REST-ful, &amp;c.) web application, people will be writing modern (MVC, stateless, REST-ful, blah, blah, blah) applications that have web interfaces, email interfaces, and whatever other interfaces they need.</p>
<p><em><a title="Feeeed me, RSSeymour!" href="http://glyphobet.net/blog/feed/atom">Stay tuned</a> for the next installment of <a title="I'm not arrogant, I swear." href="http://glyphobet.net/blog/tag/tnbt">The next big thing</a>: <a href="http://glyphobet.net/blog/essay/397">Taking the relational out of relational databases</a>.</em></p>
<ol class="footnotes"><li id="footnote_0_352" class="footnote">More or less stateless, that is, authentication tokens like cookies notwithstanding.</li><li id="footnote_1_352" class="footnote">As well as more standalone apps than you can shake a stick at.</li><li id="footnote_2_352" class="footnote">Generating text and HTML responses for email that look good and work well in the top 75% of desktop and web email clients is a <em>lot</em> harder than testing a site&#8217;s HTML in Firefox, IE, Safari and Opera.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://glyphobet.net/blog/essay/352/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The next big thing, part 1: Resolving the conflict between Model-View-Controller and AJAX design patterns</title>
		<link>http://glyphobet.net/blog/essay/153</link>
		<comments>http://glyphobet.net/blog/essay/153#comments</comments>
		<pubDate>Mon, 21 Jan 2008 00:15:56 +0000</pubDate>
		<dc:creator>glyphobet</dc:creator>
				<category><![CDATA[essay]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[AJAXSLT]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML templating]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[model-view-controller]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[TNBT]]></category>

		<guid isPermaLink="false">http://glyphobet.net/blog/?p=153</guid>
		<description><![CDATA[or, how I learned to stop worrying and love the XMLHTTPRequest&#8230; 
This is the first part of what will become an ongoing series.
If you&#8217;ve built a website in the last few years, most likely you&#8217;ve adopted an architecture similar to Model-View-Controller, or MVC.  If not, well, either your website is terribly simple, you haven&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><em>or, how I learned to stop worrying and love the XMLHTTPRequest&#8230; </em></p>
<p><em>This is the first part of what will become <a href="http://glyphobet.net/blog/tag/tnbt">an ongoing series</a>.</em></p>
<p>If you&#8217;ve built a website in the last few years, most likely you&#8217;ve adopted an architecture similar to <a title="good wikipedia good " href="http://en.wikipedia.org/wiki/Model_view_controller">Model-View-Controller</a>, or <acronym>MVC</acronym>.  If not, well, either your website is terribly simple, you haven&#8217;t had to modify it yet, or your code is spaghetti and you should be fired. Just kidding. (Or maybe you&#8217;ve come up with an even better architecture, in which case you should share your insights with us mere mortals.)</p>
<p>In <acronym>MVC</acronym> architecture, the <em>model</em> reads and writes data to and from a back-end data-store, and organizes the relational data in a nice, hierarchical fashion to be used by the controller.  The <em>view</em> accepts input from the controller and generates output <acronym>HTML</acronym>, <acronym>XML</acronym>, <acronym>RSS</acronym>, JavaScript, <acronym>SVG</acronym>, <acronym>PDF</acronym>, or whatever you want to send to the user&#8217;s browser. And the <em>controller</em> accepts browser input, figures out what to query the model for, and picks which view to use and what data to send it.</p>
<p><img title="figure 1: The traditional MVC architecture." src="http://glyphobet.net/blog/wp-content/uploads/2008/01/mvc-1-i.png" alt="figure 1: The traditional MVC architecture." width="350" height="404" /></p>
<p><span id="more-153"></span></p>
<p>This separation is nice because changes to the database engine or relational structure are isolated from the output generation, and adding new output formats for the same data or radically modifying existing output generation is similarly isolated from the database queries. Although controllers sometimes simply pass database results through to a view, the controller stage is important because there is very often idiosyncratic processing that has to happen between user input and database access, and between results from the database and output generation.</p>
<p>There you have the state-of-the art in website architecture, circa 2002. But what happens when you take an existing <acronym>MVC</acronym> website and turn it into a responsive <acronym>AJAX</acronym> site by adding a bunch of JavaScript to update the page, via <a title="it Wikipedia good" href="http://en.wikipedia.org/wiki/XMLHTTPRequest">XMLHTTPRequest</a><sup>1</sup>, without refreshing the page? You have to add views that generate <acronym>XML</acronym> as well as <acronym>HTML</acronym>, often for the same queries.  You have to generate or modify <acronym>HTML</acronym> browser-side by accessing the <acronym>DOM</acronym> with JavaScript, and often this <acronym>HTML</acronym> must exactly match the <acronym>HTML</acronym> generated for similar data by your server-side view.</p>
<p><img title="figure 2: This is your web app on AJAX. Any questions?" src="http://glyphobet.net/blog/wp-content/uploads/2008/01/mvc-2-i.png" alt="figure 2: This is your web app on AJAX. Any questions?" width="451" height="404" /></p>
<p>Suddenly half of the benefit of using <acronym>MVC</acronym> is gone; your output <acronym>HTML</acronym> generation is no longer nicely encapsulated in a single set of views on the server side;  it&#8217;s spread out across two separate parts of the code, which use two different languages (JavaScript and whatever you wrote your web app in), two different kinds of input (<acronym>XML</acronym> from the <acronym>XML</acronym> <acronym>HTTP</acronym> response or native language objects from your controller), and two different ways of generating <acronym>HTML</acronym> (<acronym>DOM</acronym> or whatever templating language you use),  and you have more JavaScript to test on different browsers.  Yuck.</p>
<p>With an architecture like this, you might as well go back to the good old days when web apps mixed <acronym>SQL</acronym> generation, <acronym>SQL</acronym> queries, and <acronym>HTML</acronym> fragment generation in a single function. Yee-haw!</p>
<p>How can you clean this architecture up?  First, focus on what you can&#8217;t avoid.  If you&#8217;re building a responsive <acronym>AJAX</acronym> web app that uses XMLHTTPRequest, you <em>cannot</em> avoid generating <acronym>HTML</acronym> with JavaScript.  What would happen if you moved <em>all</em> of your <acronym>HTML</acronym> generation to JavaScript? The views on the server-side would generate <em>only</em> <acronym>XML</acronym> responses for <acronym>XML</acronym> <acronym>HTTP</acronym> requests from JavaScript. In the browser, your app would consist of <em>static</em> <acronym>HTML</acronym> and <em>static</em> JavaScript that queries the server for data when the page loads, and whenever user action requires it.</p>
<p><img title="figure 3: The simplified MVC + AJAX architecture." src="http://glyphobet.net/blog/wp-content/uploads/2008/01/mvc-3-i.png" alt="figure 3: The simplified MVC + AJAX architecture." width="444" height="404" /></p>
<p>Suddenly your <acronym>HTML</acronym> generation is nicely encapsulated in a single place again.  And the &#8220;view&#8221; in your <acronym>MVC</acronym> web app generates only <acronym>XML</acronym>. From the browser&#8217;s point of view, the JavaScript is a kind of model, querying a back-end engine (the web server) for data and massaging it into a form that the controller (the <acronym>HTML</acronym>) can display.</p>
<p>Now, this architecture is a bit idealistic.  You&#8217;re not going to want to give up your powerful server-side templating language and do <em>all</em> your <acronym>HTML</acronym> generation in JavaScript with the woefully inadequate <acronym>DOM</acronym> interface (or worse, with <code>document.write</code> and <code>.innerHTML</code>).  You&#8217;re still going to have to generate formats other than <acronym>HTML</acronym> server side, like <acronym>PDF</acronym>s or RSS feeds.  You might want to use the JavaScript <acronym>HTML</acronym> generation pattern for some of the more dynamic features of your site, and server-side <acronym>HTML</acronym> generation for other, more static, features.  But <acronym>MVC</acronym> is an idealistic goal too &#8212; even the best-compartmentalized <acronym>MVC</acronym> apps probably have bits of controller code sprinkled in views and models. Once you start down this road, you&#8217;ll find it harder and harder to justify server-side <acronym>HTML</acronym> generation at all.</p>
<p>When I stumbled across <a title="why are they using sourceforge instead of google code?" href="http://goog-ajaxslt.sourceforge.net/">Google&#8217;s <acronym>AJAXSLT</acronym></a> a few years ago, I wondered why on earth anyone would take the time to implement the (bizarre) <acronym>XSL</acronym> templating language in JavaScript (also not my favorite language). Now I know. It lets you generate <acronym>HTML</acronym> in JavaScript based on <acronym>XML</acronym> responses from a web server.  You could even use <acronym>AJAXSLT</acronym> to fetch <acronym>XSL</acronym> templates from a server, and if your server-side views were in <acronym>XSLT</acronym> too, you&#8217;d be able to use the same <acronym>XSLT</acronym> to generate <acronym>HTML</acronym> on the browser and server sides.</p>
<p>Another solution would be to keep generating <acronym>xHTML</acronym> server side, and write JavaScript to copy that <acronym>xHTML</acronym> verbatim, from the <acronym>XML</acronym> <acronym>HTTP</acronym> response, into the <acronym>DOM</acronym>.  Either way, you still have JavaScript updating static <acronym>HTML</acronym>.</p>
<p>If you&#8217;re still doubting that this is the way to go, go to Gmail and view the source.  It&#8217;s almost all JavaScript. None of the buttons or links that you see in the page are actually in the source <acronym>HTML</acronym> &#8212; they are all generated on the fly by JavaScript. This is not to say that Google&#8217;s <em>always</em> right, or that they are doing <em>exactly</em> this; it just shows that it <em>is</em> possible to write a complex web app where the <acronym>HTML</acronym> is generated by JavaScript.</p>
<p>There&#8217;s one final missing part to this parallel between <acronym>MVC</acronym> on the server side and JavaScript model and <acronym>HTML</acronym> controller on the browser side. What&#8217;s the analogue of view on the browser? It&#8217;s supposed to be <acronym>CSS</acronym>.  The <acronym>HTML</acronym> is supposed to represent the abstract, hierarchical nature of the information being displayed.  And just as the controller feeds hierarchical objects to the view, the <acronym>HTML</acronym> provides hierarchical data for the <acronym>CSS</acronym> to style.</p>
<p>Separating <acronym>CSS</acronym> into layout/spacing <acronym>CSS</acronym>, and color/background <acronym>CSS</acronym> makes it easy to allow users to choose, or make their own color themes without royally screwing up layout.</p>
<p><img title="figure 4: MVC on the server, JS-HTML-CSS in the browser." src="http://glyphobet.net/blog/wp-content/uploads/2008/01/mvc-4-i.png" alt="figure 4: MVC on the server, JS-HTML-CSS in the browser." /></p>
<p>Unfortunately, <acronym>CSS</acronym> is still woefully inadequate for this job, but it&#8217;s nice to dream, isn&#8217;t it?</p>
<p>In the end, this isn&#8217;t so much of an <acronym>AJAX</acronym> vs. <acronym>MVC</acronym> deathmatch as it is a JavaScript-<acronym>CSS</acronym>-<acronym>HTML</acronym> meets Model-View-Controller hippie love-fest. It is possible to retain the modularization of the Model-View-Controller pattern and still write a modern, responsive web app, by extending the <acronym>MVC</acronym> pattern into the code running on the browser.</p>
<ol class="footnotes"><li id="footnote_0_153" class="footnote">For simplicity, I&#8217;m going to ignore <a title="wikipedia it good" href="http://en.wikipedia.org/wiki/JSON">JSON</a>, &lt;iframe&gt;, and other ways of communicating with the server without refreshing the page. However, the same problem exists: generating some HTML in JavaScript, and some on the server, is messy. Also, JSON is ugly and <a href="http://www.fortifysoftware.com/servlet/downloads/public/JavaScript_Hijacking.pdf">insecure</a>.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://glyphobet.net/blog/essay/153/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->