<?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>BLARGH!! for the people &#187; rants</title>
	<atom:link href="http://blargh.tommymontgomery.com/category/rants/feed/" rel="self" type="application/rss+xml" />
	<link>http://blargh.tommymontgomery.com</link>
	<description>It&#039;s time to bring forth the rhythm and the rhyme</description>
	<lastBuildDate>Fri, 09 Jul 2010 04:03:13 +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>PHP is Dead</title>
		<link>http://blargh.tommymontgomery.com/2010/07/php-is-dead/</link>
		<comments>http://blargh.tommymontgomery.com/2010/07/php-is-dead/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 04:03:13 +0000</pubDate>
		<dc:creator>tmont</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://blargh.tommymontgomery.com/?p=528</guid>
		<description><![CDATA[PHP is dead. Probably.
Allow me to preface this with some context. I ]]></description>
			<content:encoded><![CDATA[<p>PHP is dead. Probably.</p>
<p>Allow me to preface this with some context. <span style="color: #FF99FF">I <3 PHP</span>. It&#8217;s probably my favorite language for a variety of reasons, but the number one reason being I&#8217;m pretty expert at it. But I&#8217;m not above recognizing that the majority of PHP programmers are generally idiot script kiddies, and don&#8217;t know how to write code that is not terrible. In that way, all PHP programmers get a bad name, because, like in all other aspects of life, the morons far outnumber us geniuses. It&#8217;s our cross to bear.</p>
<p>Anyway, PHP is dead. Probably. Here&#8217;s why.</p>
<h2>PHP is Stagnating</h2>
<p>PHP 4 was released in <a href="http://www.php.net/archive/2000.php">May 2000</a>. PHP 5 was released in <a href="http://www.php.net/archive/2004.php#5.0.0">July 2004</a>. PHP 4.4 was released in July 2005. PHP 5.3 was released in <a href="http://www.php.net/archive/2009.php#id2009-06-30-1">June 2009</a>.</p>
<p>These dates are not enumerated here to poke fun at the slow release cycle of PHP (I&#8217;ll get to the core team later). Rather, it&#8217;s to illustrate a point. Here are some numbers that I pulled from some random data dump from <a href="http://www.nexen.net/chiffres_cles/phpversion/18829-toutes_les_stats_php_en_telechargement.php">some non-English site</a> that&#8217;s probably totally legit:</p>
<pre class="brush: sql;">
SELECT
	SUBSTRING(libelle, 1, 1) `php version`,
	SUM(nombre) `count`
FROM stats
WHERE libelle REGEXP '^[3-6](\\.\\d(\\.\\d)?)?$'
AND `date` LIKE '2008-10-06%'
GROUP BY SUBSTRING(libelle, 1, 1)
</pre>
<pre class="brush: plain;">
php version  count
-----------  -------
3               8096
4            2396211
5            1977067
6                 23
</pre>
<p>If it&#8217;s not abundantly clear to you unwashed masses what a &#8220;libelle&#8221; is, I&#8217;m pretty sure that&#8217;s &#8220;label&#8221; in some kind of European language. The dataset represents a census documenting what technologies people use to power their sites. Basically, this query is saying that in October of 2008, 2.3 million people used PHP 4 on their website and 1.9 million people used PHP 5 on their web site.</p>
<p>At that time, PHP 5 had been stable for 4 years, and PHP 4 had been stable for 8 years. Their usage in production is pretty much even. PHP 5 added a lot of features, such as, you know, <strong>object-oriented programming</strong>. And yet it takes ten years (and counting) for PEAR to get off their asses and convert their code to PHP 5.</p>
<p>For those who don&#8217;t know, PEAR is the PHP Extension Application Repository. It&#8217;s a packaging mechanism similar to <kbd>yum</kbd> or <kbd>apt-get</kbd>, as well as a repository for extensions to the PHP language written in PHP (as opposed to PECL, which are extensions to the PHP language written in C). It defined a coding standard, and generally did a lot of good for the PHP community, except that it&#8217;s written in freaking PHP 4, and the coding standard is embarrassingly terrible.</p>
<p>For example, they prefix member variables with underscores to indicate that it&#8217;s not public, since PHP 4 didn&#8217;t have the notion of member variable accessibility. PHP 4 also didn&#8217;t have the notion of static. You should see the way they implement the singleton pattern in PHP 4. It&#8217;s pretty hilarious.</p>
<p>PHP 4 also didn&#8217;t pass objects by reference. That means you manually had to insert ampersands <strong>everywhere</strong> to make sure that your objects wouldn&#8217;t be treated like a value type. And when I say everywhere, I mean everywhere. This is a very common occurrence in PHP 4:</p>
<pre class="brush: php;">
$myReferenceType =&amp; new AwesomeClass();
</pre>
<p>DEAR GOD YOU COULDN&#8217;T EVEN USE THE NEW KEYWORD WITHOUT EXPLICITLY DEFINING THE REFERENCE. WHY ARE PEOPLE STILL USING THIS VERSION OF PHP?</p>
<p>This is all a long way of saying that PHP 4 is hideously outdated, both in calendar time and technologically, and yet it remains very prominent. I die a little inside when I see someone using a host that&#8217;s rocking Apache 1.3 and PHP 4.3. It&#8217;s like seeing someone using the cgi-bin directory. Aren&#8217;t we past that yet? This isn&#8217;t 1997 anymore.</p>
<p>The same argument goes for PHP 5.3 as well. It added some sorely missing features, such as namespaces and true anonmyous functions, as well as a plethora of classes in the SPL, and yet no one is upgrading. It&#8217;s been a year, and people are still creating classes called <kbd><strong>Awesome_Controller_Abstract</strong></kbd> instead of using namespaces like a normal person. It&#8217;s heartbreaking.</p>
<p>This is what will cause PHP to always be slightly behind the curve technologically: its users&#8217; snail&#8217;s pace upgrade rate. Eventually, its one strength, the extremely low barrier to entry, will be nullified as other languages figure out how to be more accessible to the masses.</p>
<h2>The PHP Core team is separated from reality</h2>
<p>So, I imagine this is a problem for a lot of languages, and I&#8217;m definitely making unfair blanket statements, but I want to bring it up for one very specific reason. Try to read the next sentence without laughing.</p>
<p><code>In PHP, the namespace separator is the backslash.</code></p>
<p>You laughed, didn&#8217;t you?</p>
<p>Allow me to give a bit of backstory without citing any sources.</p>
<p>There was fairly raging debate among the core developers on what to use for the namespace separator in the months before PHP 5.3 was released. You see, it wasn&#8217;t as simple as you might think, because PHP isn&#8217;t primarily an object-oriented language.</p>
<p>The original solution was to use the <a href="http://php.net/manual/en/keyword.paamayim-nekudotayim.php">paamayim nekudotayim</a> (<strong>scope resolution operator</strong>, but the Hebrew version is way cooler) as a namespace separator. But oh no! That caused problems in situations like this:</p>
<pre class="brush: php;">
//bar.php
namespace Bar;

function foo() {}

//meanwhile, in baz.php
require_once bar.php;

class Bar {
  static function foo() {}
}

Bar::foo(); //which foo gets called? in the Bar namespace or in the Bar class?
</pre>
<p>So, the core team realized they had a problem. There were several solutions:</p>
<ol>
<li>Only apply namespaces to OO code (classes, interfaces, etc.)</li>
<li>Change the namespace separator character to something unambiguous</li>
</ol>
<p>Hindsight is always 20/20, but the second option there seems pretty retarded to me. It&#8217;s hard to find an unambiguous character in any language that has previous releases, because they&#8217;re all being used. What happens is you&#8217;ll end up choosing a character that&#8217;s hard to type (i.e. one you have to press shift for), or you&#8217;ll choose something that&#8217;s unambiguous technically (meaning not significantly used) but has ambiguous semantics (like, say, the escape character in every language besides T-SQL).</p>
<p>At one point, the core team actually created a matrix where each row was a different character (I think the triple colon was in the running at one point, which would probably be even more awesome when translated to Hebrew), and each column had funny stuff like &#8220;is hard to type&#8221; with a numeric value. The last column summed up the numeric values and the row with the highest number was the winner. It was all very democratic (THROUGH PURPLE MOUNTAIN MAJESTIES&#8230;).</p>
<p>The backslash won.</p>
<p>Well, kind of. Pretty much everybody who typed code for a living hated the backslash because, you know, IT&#8217;S THE BACKSLASH. Nobody wants to look at that.</p>
<p>But PHP is an open source project, which means most or all of them don&#8217;t get paid to work on it, so that means that the easiest solution will win. And in this case, the easiest solution was the one that was already done. One of the core developers got tired of the bickering and the matrices and the Hebrew and he spent a weekend implementing the backslash namespace separator and committed it to the branch. Then he wrote tests covering all possible cases, and created a patch against trunk.</p>
<p>He had everyone at &#8220;tests&#8221; and &#8220;patch&#8221;. And that&#8217;s how the backslash became the namespace separator for PHP.</p>
<p>This was all a a long way of saying their decision was made with their brains instead of their guts. If they used their guts, they would have realized that NOBODY GIVES A CRAP ABOUT NAMESPACES EXCEPT PEOPLE WHO DO OBJECT-ORIENTED CODE. Nobody cares if the 4000 lines of random functions in <kbd>stuff.php</kbd> is in a namespace. The only people who care about namespaces are those that experienced it in another language (like say, an object-oriented language) and would want to apply the same organizational structure to their PHP code. And those people are only writing classes and interfaces. </p>
<p>Ergo, they should have ignored the collision issues illustrated above, only applied namespaces to classes and interfaces, and rocked the <strong>PAAMAYIM NEKUDOTAYIM</strong> like it was going out of style. But since the PHP core team are experts in C, not PHP, they didn&#8217;t really realize this.</p>
<p>Instead, we are condemned to a life full of backslashes. I&#8217;ve already started a support group.</p>
<h2>PHP 6 is a disaster area</h2>
<p>I don&#8217;t have a lot to say about this, except that it seems like it&#8217;s an absolute disaster. The main thing going on in PHP 6 is unicode support. </p>
<p><code>yay.</code></p>
<p>I&#8217;m not totally sure why that&#8217;s so awesome, but it&#8217;s a lot of work, and it isn&#8217;t going well. Again I&#8217;m not going to cite any sources, but it&#8217;s been in the works for about two years to add unicode support to PHP, and I don&#8217;t think it&#8217;s very close to being done.</p>
<p>The problem seems to be that they can&#8217;t just add unicode support, because every extension would be incompatible. So they&#8217;re trying to retroactively add unicode support to everything at once, which is as terrible as it sounds. I could be making all this up, but it sounds similar to something I might have read once.</p>
<p>Basically, they&#8217;re attempting to add a feature that will be of minimal value, and it&#8217;s taking forever. Instead, they could be adding cool things, like some of these:</p>
<ul>
<li><a href="http://wiki.php.net/rfc/propertygetsetsyntax">C#-style properties</a></li>
<li><a href="http://wiki.php.net/rfc/autoboxing">Auto-boxing</a></li>
<li><a href="http://wiki.php.net/rfc/horizontalreuse">Traits</a></li>
<li><a href="http://wiki.php.net/rfc/enum">Enumerations</a></li>
<li><a href="http://wiki.php.net/rfc/fcallfcall">Function call chaining</a> (oh god yes)</li>
<li><a href="http://wiki.php.net/rfc/static-classes">Static classes</a></li>
</ul>
<h2>In Conclusion</h2>
<p>PHP is dying. Probably. I hope I&#8217;m wrong, because I think PHP is a very expressive, convenient language. It has, by far, the best function library of any language. It also has, by far, the best documentation of any language, as well as a giant, open community around it. For those reasons, I hope it doesn&#8217;t die. But I&#8217;ve seen little evidence that it&#8217;s not going to march straight to hell.</p>
]]></content:encoded>
			<wfw:commentRss>http://blargh.tommymontgomery.com/2010/07/php-is-dead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reddit in 61 minutes and 97 lines of PHP</title>
		<link>http://blargh.tommymontgomery.com/2010/02/reddit-in-61-minutes-and-97-lines-of-php/</link>
		<comments>http://blargh.tommymontgomery.com/2010/02/reddit-in-61-minutes-and-97-lines-of-php/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 11:04:29 +0000</pubDate>
		<dc:creator>tmont</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://blargh.tommymontgomery.com/?p=398</guid>
		<description><![CDATA[I read this article, about a guy who made a Reddit clone in 10 minutes in Clojure. He was inspired by this guy, who made a Reddit clone in Lisp in 20 minutes and a hundred lines.
I&#8217;m so sick of Lisp hackers. Functional programming is pretty awesome, but every single Lisp/Erlang/Haskell/Clojure/Emacs guy thinks Lisp is [...]]]></description>
			<content:encoded><![CDATA[<p>I read <a href="http://www.bestinclass.dk/index.php/2010/02/reddit-clone-in-10-minutes-and-91-lines-of-clojure/">this article</a>, about a guy who made a Reddit clone in 10 minutes in Clojure. He was inspired by <a href="http://homepage.mac.com/svc/LispMovies/index.html#2">this guy</a>, who made a Reddit clone in Lisp in 20 minutes and a hundred lines.</p>
<p>I&#8217;m so sick of Lisp hackers. Functional programming is pretty awesome, but every single Lisp/Erlang/Haskell/Clojure/Emacs guy thinks Lisp is the greatest thing since list processing (what?).</p>
<p>So I implemented Reddit in (properly formatted) PHP in 97 lines. Granted it took a bit longer, but I had to remember how to use the low-level <kbd>mysql_*</kbd> functions. Oh, and I used MySQL. I don&#8217;t know what the Lisp people used for data persistence. Some of the lines were taken up by CSS and JavaScript, and making things look nice(r).</p>
<div id="attachment_399" class="wp-caption aligncenter" style="width: 341px"><img src="http://blargh.tommymontgomery.com/wp-content/uploads/2010/02/redditclone.png" alt="Reddit in 61 minutes of alone time with Notepad++" title="redditclone" width="331" height="261" class="size-full wp-image-399" /><p class="wp-caption-text">Reddit in 61 minutes of alone time with Notepad++</p></div>
<p><a href="http://tmont.com/experiments/reddit-php-lol/source.php">Source</a> | <a href="http://tmont.com/experiments/reddit-php-lol/">Playground</a></p>
<p>I hate Lisp people.</p>
]]></content:encoded>
			<wfw:commentRss>http://blargh.tommymontgomery.com/2010/02/reddit-in-61-minutes-and-97-lines-of-php/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>top != self and fun with the Tokelauans</title>
		<link>http://blargh.tommymontgomery.com/2010/01/top-self-and-fun-with-the-tokelauans/</link>
		<comments>http://blargh.tommymontgomery.com/2010/01/top-self-and-fun-with-the-tokelauans/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 09:42:04 +0000</pubDate>
		<dc:creator>tmont</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://blargh.tommymontgomery.com/?p=388</guid>
		<description><![CDATA[I noticed recently that THE GREATEST SITE IN THE WORLD had a new referrer. I checked it out, and saw this:

A touch of JavaScript, and now they see this:

Just say NO to frames. And kiwis.
]]></description>
			<content:encoded><![CDATA[<p>I noticed recently that <a href="http://urmomisugly.com/">THE GREATEST SITE IN THE WORLD</a> had a new referrer. I checked it out, and saw this:</p>
<p><img src="http://blargh.tommymontgomery.com/wp-content/uploads/2010/01/kiwifail.png" alt="kiwifail" title="kiwifail" width="634" height="316" class="aligncenter size-full wp-image-389" /></p>
<p>A touch of JavaScript, and now they see this:</p>
<p><img src="http://blargh.tommymontgomery.com/wp-content/uploads/2010/01/kiwifail2.png" alt="kiwifail2" title="kiwifail2" width="382" height="121" class="aligncenter size-full wp-image-390" /></p>
<p><a href="http://www.buduglydesign.com/frame9806/hateframe.html">Just say NO to frames</a>. And kiwis.</p>
]]></content:encoded>
			<wfw:commentRss>http://blargh.tommymontgomery.com/2010/01/top-self-and-fun-with-the-tokelauans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Test Driven Design Fails</title>
		<link>http://blargh.tommymontgomery.com/2009/12/when-test-driven-design-fails/</link>
		<comments>http://blargh.tommymontgomery.com/2009/12/when-test-driven-design-fails/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 03:29:53 +0000</pubDate>
		<dc:creator>tmont</dc:creator>
				<category><![CDATA[coders at work]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blargh.tommymontgomery.com/?p=274</guid>
		<description><![CDATA[In the last couple years, there has been a lot of buzz around things like &#8220;Agile&#8220;, &#8220;Scrum&#8220;, &#8220;TDD&#8220;, and other stupid stuff that wraps an acronym around common sense. Basically, they&#8217;re all a way for people to make money by writing books telling people how to develop software. The target market is non-technical managers, developers [...]]]></description>
			<content:encoded><![CDATA[<p>In the last couple years, there has been a lot of buzz around things like &#8220;<a href="http://en.wikipedia.org/wiki/Agile_software_development">Agile</a>&#8220;, &#8220;<a href="http://en.wikipedia.org/wiki/Scrum_%28development%29">Scrum</a>&#8220;, &#8220;<a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>&#8220;, and other stupid stuff that wraps an acronym around common sense. Basically, they&#8217;re all a way for people to make money by writing books telling people how to develop software. The target market is non-technical managers, developers who aren&#8217;t very good at their job, and executives who enjoy acronyms.</p>
<p>It&#8217;s not all bad, though. Agile and scrum are basically a fancy way of saying &#8220;communicate more&#8221;, and if you can get &#8220;the business&#8221; to talk to you more and all it takes is an overloaded word like &#8220;scrum&#8221;, go for it. Mostly, though, I hear &#8220;scrum&#8221; and &#8220;agile&#8221; and &#8220;tdd&#8221; as cop-out explanations used by developers to explain why they aren&#8217;t very good at their jobs.</p>
<ul>
<li><em>The project is late because the requirements were constantly changing.</em></li>
<li><em>We didn&#8217;t catch the bug because we didn&#8217;t have enough time for testing</em></li>
<li><em>100% code coverage is impossible</em></li>
</ul>
<p>All of these issues can be solved by being better at your job. Learn how to communicate with your customers. Learn how to budget your time. Learn how to write tests. Scrum and agile and tdd <strong>mitigate</strong> these issues, they don&#8217;t solve them. They <strong>force</strong> you to communicate, and write tests, but if you&#8217;re not <strong>good</strong> at communicating or writing tests, doing more of it isn&#8217;t going to help you.</p>
<p>Of course, if your manager is an idiot, then you&#8217;re screwed, and you will always have these problems.</p>
<p>But this article is less about whining in general and more about whining about TDD. Let&#8217;s commence.</p>
<h2>Case Study: Sudoku Solver</h2>
<p>Peter Norvig works at Google as Director of Research (I&#8217;m sure that actually means something) and before that he worked at NASA as some kind of AI genius/hacker. He&#8217;s a smart guy who&#8217;s been programming for a long time.</p>
<p>In <a href="http://blargh.tommymontgomery.com/category/coders-at-work/">Coders at Work</a>, Norvig talks about a TDD experience of his involving an algorithm for solving Sudokus. It was interesting to me because I wrote a Java applet (shudder) to do that for a college assignment. It was an interesting problem involving recursion, threading, backtracking, memoization and other stuff that academics love.</p>
<p>What happened is that he wrote an algorithm to solve them, and then someone else, from the TDD community, saw it and attempted to write the same algorithm using test driven development: that is, by writing the tests first, and allowing the tests to influence the design of the algorithm.</p>
<blockquote><p>It&#8217;s also important to know what you&#8217;re doing. When I wrote my Sudoku solver, some bloggers commented on that. They said, &#8220;Look at the contrast&mdash;here&#8217;s Norvig&#8217;s Sudoku thing and then there&#8217;s this other guy, whose name I&#8217;ve forgotten, one of these test-driven design gurus. He starts off and he says, &#8220;Well, I&#8217;m going to do Sudoku and I&#8217;m going to have this class and first thing I&#8217;m going to do is write a bunch of tests.&#8221; But then he never got anywhere. He had five different blog posts and in each one he wrote a little bit more and wrote lots of tests but he never got anything working because he didn&#8217;t know how to solve the problem.</p>
</blockquote>
<p>The problem that the TDD guy encountered was twofold:</p>
<ol>
<li>He didn&#8217;t know anything about Sudoku</li>
<li>He tried to solve that by writing tests</li>
</ol>
<p><strong>Tests are not a replacement for knowledge.</strong> That seems like a stupid statement, but it&#8217;s something that a lot of TDD/Agile advocates sometimes forget. They might complain that we&#8217;re not practicing scrum correctly, but practicing scrum correctly doesn&#8217;t guarantee that anything will get better. Instead of blindly following a wikipedia article to determine how to run your project or write code, you should figure out what&#8217;s wrong, and then solve that in the way that makes the most sense. You might even discover that you&#8217;ll start practicing scrum correctly as a byproduct of common sense. Common sense is why most development methodologies exist. Stuffing your current situation into the fad-of-the-moment is not going to solve your problems, although it might by accident. But I wouldn&#8217;t hold your breath.</p>
<p>Anyway, back to Sudoku. The TDD guy tried to solve the Sudoku problem by writing tests for a problem he did not understand, which meant whatever tests he was writing were <strong>totally worthless</strong>, which is something <strong>he actually admits</strong> in the very first article. After five articles and a great deal of code and a great deal of tests, a Sudoku solver did not exist.</p>
<p>From the <a href="http://xprogramming.com/xpmag/OKSudoku">first article</a>:</p>
<blockquote><p>Arguably this is a violation of YAGNI, but since I don’t really know how to start or how to know when I’m done, writing some Spike code in TDD style seems to me to be a good way to get my feet wet.</p>
</blockquote>
<p>WRONG. A good way to get your feet wet is to do some research about the problem (the internet is your friend) to see if you&#8217;re going in the totally wrong direction.</p>
<blockquote><p>My plan, subject as always to change, is to code something up in that way that I have, to see what happens</p>
</blockquote>
<p>FAIL. &#8220;To see what happens?&#8221; I&#8217;m glad I don&#8217;t work with this guy. If you&#8217;re randomly writing code to determine if your plan is either absolutely perfect or absolutely idiotic, you&#8217;re doing it wrong.</p>
<p>Norvig solved the Sudoku problem by understanding the problem, understanding the solution, and then writing the code. He probably wrote some tests at some point, but they most definitely did not influence his design. What influenced his design was personal experience and a vast knowledge of search algorithms.</p>
<p>Of course, you aren&#8217;t going to have vast knowledge of every problem you&#8217;re trying to solve, but that&#8217;s not the point. The point is that writing tests first is not always the correct decision. If you don&#8217;t know anything about the problem or how to solve it, writing a test is not going to help you. All it will do is make you write a lot of code that is probably worthless.</p>
<p>Read for yourself:</p>
<ul>
<li><a href="http://norvig.com/sudoku.html">Norvig&#8217;s original Sudoku solver</a></li>
<li>The TDD approach: <a href="http://xprogramming.com/xpmag/OKSudoku">1</a>, <a href="http://xprogramming.com/xpmag/Sudoku2">2</a>, <a href="http://xprogramming.com/xpmag/SudokuMusings">3</a>, <a href="http://xprogramming.com/xpmag/Sudoku4">4</a>, <a href="http://xprogramming.com/xpmag/sudoku5">5</a></li>
<li><a href="http://pindancing.blogspot.com/2009/09/sudoku-in-coders-at-work.html">The article Norvig references</a></li>
<li><a href="http://www.infoq.com/news/2007/05/tdd-sudoku">Another summary</a></li>
</ul>
<h2>Case Study: Wiki Engine</h2>
<p>Recently, I decided to write a <a href="http://websvn.tommymontgomery.com/filedetails.php?repname=butterfly&#038;path=%2Ftrunk%2Fbutterfly.php">wiki engine</a>. Why? Because I wanted to. I&#8217;m aware of the hundreds of other wiki engines, but it&#8217;s an interesting problem, and reinventing the wheel is a lot of fun, just make sure you&#8217;re doing it on your own time.</p>
<p>Anyway, I started and stopped several times, deleting large chunks and rewriting them as I went. That is probably not the best way to develop, but whatever. At one point, I wrote a test that looked similar to this:</p>
<pre class="brush: php;">
public function testHeaderGetsParsedCorrectly() {
  $wikitext = &lt;&lt;&lt;WIKI
!Header level 1
!!Header level 2
WIKI;

  $expected = &lt;&lt;&lt;HTML
&lt;h1&gt;Header level 1&lt;/h1&gt;
&lt;h2&gt;Header level 2&lt;/h2&gt;

HTML;

  $this-&gt;assertEquals($expected, $this-&gt;wikiEngine-&gt;toHtml($wikitext));
}
</pre>
<p>Nothing wrong with that. It&#8217;s testing that the given wiki text gets transformed into the correct HTML. Pretty straightforward.</p>
<p>However, this gives me absolutely no insight to the design of the overall engine. I could easily write a function that will do this, but will it be the correct design? Let&#8217;s probe deeper.</p>
<p>I&#8217;ve written wiki engines before (they sucked). I&#8217;ve looked at other wiki engines, and done a bit of research into <a href="http://en.wikipedia.org/wiki/Lexical_analysis">Lexical Analysis</a> and <a href="http://en.wikipedia.org/wiki/LALR_parser">certain kinds of parsers</a>. I know a little bit about how to write something that parses something else. I didn&#8217;t really use any of that knowledge in my own personal wiki engine, because using <a href="http://en.wikipedia.org/wiki/Yacc">yet another parser generator</a> in a wiki engine written in PHP would be an impressive waste of my time, even from a purely academic point of view. But I digress. I was talking about why TDD was a bad idea in this situation.</p>
<p>All this test can tell me is that I need a function that should transform some text into some other text. How do I handle scoping? How do I handle block elements vs. inline elements? How do I handle escaping? Can the solutions to these problems be reused, or is it a one-off kind of thing that can be hard-coded in one place?</p>
<p>I ran into all of these problems after I had already written several tests. Everything worked, but the design was crap. There was no way I could handle a nested element (like say, a string of bold text inside a list item). I had to completely rethink my design. The amusing part is that <strong>the tests did not change</strong>, only my design. TDD utterly failed in influencing my design.</p>
<p>It could be argued that my tests were not good enough. I would argue that my tests are fine. The actual implementation of the engine is not something I care about. I don&#8217;t care if use a scope stack or if I keep track of nested elements in a different way, which is why my tests are only interested in results, not design. I could write some tests that look like the following:</p>
<pre class="brush: php;">
public function testBoldIsAddedToScopeStack() {
  $wikitext = '__bold text__';
  $this-&gt;wikiEngine-&gt;toHtml($wikitext);
  $this-&gt;assertContains(array('type' =&gt; 'strong'), $this-&gt;wikiEngine-&gt;scopeStack);
}
</pre>
<p>Oh wait, that&#8217;s an absolutely terrible design, for several reasons. First of all, the scope stack should not be publicly available. I suppose I could add a public <kbd>scopePeek()</kbd> method that just returns the last pushed scope, but why? To satisfy a unit test? Testing should influence design, but you shouldn&#8217;t sacrifice design for testing. Don&#8217;t make methods public because you can&#8217;t test them otherwise.</p>
<p>Secondly, <kbd>toHtml()</kbd> is not incremental. When I pass text into it, I want HTML returned. I can&#8217;t just parse half of it and then check that it was parsed correctly; that makes no sense for a wiki engine. There isn&#8217;t ever a time when you would want to parse something halfway. Again, I&#8217;d have to sacrifice design to satisfy my unit test. That&#8217;s not going to happen.</p>
<p>Another solution is to just not close the scope, something like this:</p>
<pre class="brush: php;">
$wikitext = '__bold text'; //no closing &quot;__&quot;
</pre>
<p>However, I want the engine to automatically close scopes when it reaches EOF. So the <kbd>toHtml()</kbd> method does that at the end automatically, which means that after I call <kbd>toHtml()</kbd> the scope stack will <em>always</em> be empty. I could move that functionality into another public function, but why would I want to expose that functionality publicly? There&#8217;s no reason. I <strong>always</strong> want to close scopes; I don&#8217;t want that decision left up to the implementer of the wiki engine.</p>
<p>In the end, there was no way for me to test that a scope got pushed onto the stack correctly. In fact, I realized that I really didn&#8217;t want to test that anyway. What if I wanted to change the scope stack to a queue? Then I&#8217;d have dozens of breaking tests because now the internal data structure is FIFO instead of LIFO. Is that something that should be tested? In my opinion, absolutely not. A long as the parsing works correctly, I don&#8217;t particularly care about the internal data structure of the engine. If performance is a concern, I can write tests to verify that parsing some hideously long whiny anti-TDD article takes x amount of seconds at the most. Then if a change to the internal data structure causes that test to break, then I know I&#8217;ve got something to fix. In that way TDD could influence my design, but up front, there&#8217;s no test that could have told me what my design should look like. I had to analyze problems that were hidden to the public interface and solve them without tests.</p>
<p>This seems a rather contrived example, but it&#8217;s an example that I encountered while trying to employ TDD to help me write some code (IRL, as it were). The fact is, this methodology <strong>just didn&#8217;t work</strong> for this problem. It was creating hindrances and forcing me to sacrifice a solid, safe design for the sake of testing something that didn&#8217;t really need to be tested. And it didn&#8217;t even give me the help I needed, which was how to construct the internal engine so that nested elements were rendered correctly. The fact is that I needed more experience in parsing engines before I could confidently design a parser that correctly handled nested scopes. This was something that required some trial and error before a design that solved the problem emerged. TDD wasn&#8217;t going to give me that no matter what kind of tests I wrote.</p>
<h2>Conclusion</h2>
<p>I&#8217;m not here to bash testing. I&#8217;m all for testing, in ways that might <a href="http://tommymontgomery.com/projects#Testify">surprise you</a>. I&#8217;m all for testing in ways that make people develop better. Some people just aren&#8217;t suited for TDD, and not every problem requires a unit test. In most cases, common sense will solve more problems than writing a test ever would.</p>
<p>And if anyone actually looks at my wiki engine, I had specific goals in mind, which is why it&#8217;s shoved in one giant class and uses arrays for stuff instead of objects. I don&#8217;t want to hear it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blargh.tommymontgomery.com/2009/12/when-test-driven-design-fails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Everybody is Losing the Browser Wars</title>
		<link>http://blargh.tommymontgomery.com/2009/08/why-everybody-is-losing-the-browser-wars/</link>
		<comments>http://blargh.tommymontgomery.com/2009/08/why-everybody-is-losing-the-browser-wars/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 04:37:40 +0000</pubDate>
		<dc:creator>tmont</dc:creator>
				<category><![CDATA[rants]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blargh.tommymontgomery.com/?p=82</guid>
		<description><![CDATA[Recently, I read about RockMelt, an upcoming new browser that is apparently &#8220;endorsed&#8221; by the guy who started Netscape. The description of RockMelt made me start thinking about how every browser sucks, and why this new one doesn&#8217;t appear to be trying to buck the trend of suck. But first, a brief, slightly egocentric history [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I read about <a href="http://rockmelt.com/">RockMelt</a>, an upcoming new browser that is apparently &#8220;endorsed&#8221; by the <a href="http://en.wikipedia.org/wiki/Marc_Andreessen">guy who started Netscape</a>. The description of RockMelt made me start thinking about how every browser sucks, and why this new one doesn&#8217;t appear to be trying to buck the trend of suck. But first, a brief, slightly egocentric history of the suck.</p>
<h2>In Review: A History of Suck</h2>
<p> In the early 90s, it was all about Netscape Navigator and its little ship helm logo. Anybody who was in junior high in the 90s should have seen it. Then, while Netscape basked in its glory, doing nothing to improve itself, along came IE and the little blue E that we&#8217;ve all come to know and <del datetime="2009-08-15T20:57:51+00:00">love</del> despise with the wrath of a thousand suns. Netscape pretty much disappeared, largely due to the fact that the early IEs were much, much better, and also because everyone started using Windows, which of course shipped with IE (since it was made by Microsoft).</p>
<p>The pinnacle of browser beauty culminated in the advent of Internet Explorer 6 in the late 90s, and pretty much spelled the doom for Netscape, which hadn&#8217;t been significantly improved for 6 years. You could look at futhermucking PNGs with IE! How could Netscape possibly compete with that!?</p>
<p>Anyway, IE and Microsoft enjoyed its reign as king of browsers, until Netscape realized they had no hope of ever competing because they were ugly and lazy and stupid. So they sold their souls to the Mozilla corporation, which took out all of the good stuff in Netscape (the Gecko engine), and left the suck to rot in versions 8 and 9. They created Firefox, which hipsters and linux geeks the world over have heralded as the second coming of Christ. Firefox basically was just a way for nerds to assert their superiority over other nerds by name-dropping it. Because everyone knows that if you haven&#8217;t heard of Firefox, you can haz a n00b. Kind of like what I did with RockMelt several paragraphs ago. Try to keep up.</p>
<p>Meanwhile, a bunch of Norwegians, in true viking style, started their own browser called &#8220;Opera&#8221;. I can only assume they named it something so lame because of the language barrier. Opera began being used by an even smaller clique of nerd know-it-alls than Firefox. They are even more annoying than their Firefox counterparts, albeit less vocal. Opera proclaimed a love for standards-compliant (an admirable goal), lightweight, portable browsers, and they pretty much succeeded. Unfortunately, nobody gives a crap, because it looks hideous.</p>
<p>Back at Microsoft, the genius engineers behind IE6 were enjoying their throngs of groupie women, failing to realize that in the last 10 years <em>things have actually happened</em>! Say what!? IE6 is a horrible, horrible abomination? I thought we could just build an application and then let it stagnate for a decade and it would still be awesome! How did we miss this!?</p>
<p>Microsoft scrambled to alleviate the most vocal of the complaints against IE6 (&#8220;no tabbed browsing!? what is this, the 12th century? Firefox is safer LOLZ&#8221;). IE7 came out, to no buzz whatsoever. Since all the people who knew how to use the web were already using Firefox (all 20 of them), and most people turn off automatic Windows updates as soon as they plugin their computers, IE7 was pretty much not adopted by anyone. All it really did was give web developers one more browser to test. Granted, in terms of standards compliance, it was <em>far</em> better than IE6 (transparent PNGs <em>gasp!</em>), but it was still worse than Firefox 1.5. And Opera. So nobody was converted, but frankly, that wasn&#8217;t really the goal of IE7 anyway, because IE still had 95% of the market share anyway. They were still sitting pretty, until&#8230;</p>
<h3>Mozilla Add-Ons, or How Firefox Lessened the Suck</h3>
<p>This was Mozilla&#8217;s most brilliant breakthrough, and frankly, it&#8217;s the only thing that&#8217;s currently keeping people from switching to a browser that doesn&#8217;t require 300MB of memory to sit idly. Mozilla created this thing called XUL, but didn&#8217;t put it to good use until they created the addons site, and people actually started using it. Suddenly, the browser wasn&#8217;t just an application, it was a <em>way of life</em>. The Firefox bigots finally had a solid reason why their browser was better: it was customizable. In a way in which pretty much no other desktop application was. It really was and is still a remarkable amount of genius. <a href="http://getfirebug.com/">Firebug</a> is the <strong>only</strong> only that reason I still use Firefox. It&#8217;s bloated, slow, resource-intensive, ugly, and its users are among the most annoying on the internet, but it&#8217;s the only way I can actually debug anything on the web.</p>
<p>Meanwhile, in Microsoft Land, IE7 was stagnating (surprise). Business managers are mostly Nazis (Godwin&#8217;s law) and don&#8217;t want anyone browsing anything besides their intranet and/or SharePoint, so they had no reason to allow their underlings to upgrade their browser to IE7. That hideous rite <a href="http://blog.digg.com/?p=878">still rages on today</a>. In Norway, Opera was developing rapidly to the tune of CSS3 and standards compliance, but nobody cares about that besides web developers, and they weren&#8217;t about to leave Firebug behind. Not to mention the fact that they were still verifying that their websites are IE4+ compatible, so any technology more recent than an animated gif was not used anyway. In version 9.5/6, Opera released Dragonfly, their own version of Firebug, which was a giant step forward, but still much worse than Firebug. Nobody was converted. The market share had shifted slightly in favor of Firefox, but IE still held a commanding 4:1 lead.</p>
<h3>Google Starts Sucking, Too</h3>
<p>Then, suddenly, a new player emerges! Google enters the fray with Chrome, a brand new browser!&#8230; Except that there wasn&#8217;t anything new or innovative about it. The one nice feature that Chrome had was that each tab was its own process, which meant that while Flash was busy crashing in one tab, the other tabs would independently and cheerfully continue to load&#8230;. Until they eventually crashed as well. Chrome captured approximately 2% of the market, which is actually pretty impressive for a browser that has nothing to offer, besides the coolness of its brand. That figure is even more impressive when you factor in how it was only available on Windows for over 6 months.</p>
<p>And here we are, in 2009, with about three browsers to choose from, all with huge, gaping flaws. You&#8217;ll notice that I left Safari out of this little anecdote. That&#8217;s because it was an <em>egocentric</em> history of browsers, and I&#8217;ve never used Safari except for testing, and marveling at how incredibly difficult it is to turn on the JavaScript error console (<kbd>defaults write com.apple.Safari IncludeDebugMenu 1</kbd>: are you %@#!ing kidding me!?).</p>
<h2>A Full Circle</h2>
<p>So, why did I go through all the trouble of outlining this? My negativity towards browsers is universal, as I&#8217;ve sampled all of the major ones and a few of the minor ones, and they all have one thing in common: sucking. The world of technology is evolving. Even though the open source community is strong, all of those people have day jobs because they can&#8217;t make a living by writing awesome software. They write awesome software on the side while they support their families by implementing <strong>SOA</strong> through <strong>REST</strong> visa vis <strong>SaaS</strong>. The software industry is a wave of fads and trends that executives latch onto to try and be the next Google, despite the fact that companies like Google <em>never</em> employed such empty things like SOA. Well, maybe they did indirectly, but that was never their strategy. Every developer who has a job now is a slave to these trends, even when they&#8217;d rather not be. Money and greed rule the day; in any industry, really. It&#8217;s the one downside of capitalism: it always seems to morph into pure greed.</p>
<p>So, allow me to come full circle on how the the browser wars are similar to the trials and tribulations of the software industry. The new waves of browsers are very similar to how non-techie executives would mandate that a software application would develop. </p>
<h3>Firesuck</h3>
<p>New features in Firefox 3.5 include one-click bookmarking, an improved address bar (awesome bar), something about tabs, better memory management and session restore. Useful features, sure, but where&#8217;s support for CSS3, or improved stability of Flash, or a faster rendering engine, or more standards-compliant HTML rendering? Besides improving the memory management, they were clearly more focused on improving the user experience than improving the actual software.</p>
<p>Not that improving the user experience is bad, but when a YouTube video causes Firefox to lock up for 30 seconds, that seems like something that should be fixed before, say, a more convenient way to bookmark pages. I mean, who even uses bookmarks anyway? I have like four bookmarks (all to login pages for paying my bills online). There&#8217;s only about 10 sites that I visit on a regular basis, and I don&#8217;t have trouble remembering the fully qualified domain names of 10 sites.</p>
<h3>Unite the Suck</h3>
<p>Opera 10 introduced Unite, which basically turns Opera into a web server. Kind of cool, I guess, but how trying to take some competition away from Firefox by making Dragonfly not the slowest piece of tripe ever? Or use a font that doesn&#8217;t look like it was created by a three year old with a box of crayons? Or make the default skin less hideous? Or support JavaScript features past version 1.5? And if someone is actually smart enough to know what a web server is, they&#8217;re probably already running their own web server, and are not going to relinquish control to a web <em>browser</em>.</p>
<h3>I&#8217;m Feeling Sucky</h3>
<p>Google recently announced that their new operating system will be available in 2010 sometime, which is basically a wrapper around their browser. A novel idea, but why I would leave my current operating system for one that&#8217;s based around a browser that I don&#8217;t use? Maybe their idea will work, but I don&#8217;t think people are quite ready to turn their computers into a giant, fancy web browser. More importantly, I don&#8217;t think the web is ready for it. Connections are too slow, servers are too easily assaulted, and web applications are too unusable (compared with desktop apps) that being as productive on the web as you are on the desktop is still 10 years away.</p>
<p><a href="http://teddziuba.com/2008/09/a-web-os-are-you-dense.html">This guy</a> says it pretty well, with some MSPaint-inspired graphics to help you learn. Because learning is fun!</p>
<h2>The Conclusion</h2>
<p>The next generation of browsers need to focus on delivering content in the easiest, fastest and least painful way possible. I would happily give up 90% of the features in Firefox if the application never crashed. Firefox crashes so often that it <strong>has its own built-in crash reporter</strong>. I might use Chrome exclusively if flash didn&#8217;t crash the browser 10% of the time. I might use Opera if Dragonfly was slightly usable. I might use Safari if&#8230; well, I&#8217;ll never use Safari. I might use IE if Microsoft didn&#8217;t insist on deviating from every known web standard.</p>
<p>RockMelt, like Chrome, seems to be focusing on bridging the gap between desktop and web. Why don&#8217;t they just focus on fixing the problems with all the other browsers? What if they made an easily debuggable, solid, secure, fast, easy-to-use, lightweight browser? Instead, we&#8217;re probably going to get another Opera Unite, with the absolute latest in bookmarking technology. We&#8217;ll be able to bookmark freaking everything! Our lives will never be the same!</p>
<h3>Plz.</h3>
<p>I appeal to the browser makers: stop giving me new features, and fix the stuff that is already broken. Right now, <em>nobody</em> is winning. Let the <em><strong>users</strong></em> win the browser wars.</p>
]]></content:encoded>
			<wfw:commentRss>http://blargh.tommymontgomery.com/2009/08/why-everybody-is-losing-the-browser-wars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
