Tuesday, March 18, 2008

Bravissimo!

Dang. Every time I think Joel Spolsky's getting too big for his britches, he reminds me of why I write off 90+% of his elitism and slightly embarrassing self-promotion. The write-off is not the price of genius so much as the price of learning so much from a smart person who can also communicate. A very small price, even for my Midwestern sensibilities. (If you could take Warren Buffett or Bill Gates out for lunch--seriously, would you actually let either of them pay the bill? I would bloody well hope not.) And so I return to the "Joel on Software" blog every week or so, for something like the 8th or 9th year running.

Yesterday's Martian Headsets is a case in point. (If you have any interest whatsoever in developing for the Web, read it. Now. Yes, right this very nanosecond. If you don't come back after that--it's a looooonnnng post--that's okay. You'll gain far, far more there than you will here.)

For all that, I'm not positive that I agree that if HTML had been more retentive about standards, it would have halted the explosion of the World Wide Web during the mid/late 1990s. Here's my reasoning:

If you were an impecunious computer science student (such as I was), your development environment was Notepad. You stayed up until two in the morning figuring out that your JavaScript was blowing up on the perfectly-@#$%^&*-valid-thank-you-very-@#$%^&*-much code of Line 459 because you flipped around a curly-brace waaaaay back on Line 273. (I'm not exaggerating about that. 'Spesh'ly the profanity part. Ask Dearest.) But the bottom line was that you had to to get that code out the door, and the browser didn't give a hot cup of jack-squat what you meant to do with that curly-brace on Line 273.

If, on the other hand, you worked for one of the fifty bazillion web design firms in business back in the day, your employer could probably afford tools, which would have handled the messy details of tag-completion, tag nesting, and so forth.

In either case, strictness of standards would have not mattered as much as Mr. Spolsky makes it sound. In the latter case, the tools would have enforced rigor (as did the gawdawful homegrown SGML editors we were forced to use at IBM), or you would have learned very quickly to humor the browser's rendering engine and scripting runtime. And, in my opinion, the web would have been better for it. The sheer number of person-hours saved in keeping both Netscape and IE (and later Opera) happy would have freed up a not-insignificant amount of time for more coding.

In fairness, Mr. Spolsky makes the excellent point that standards are not always written clearly, even without intentional self-serving misinterpretation. That still doesn't exonerate the major players. Have you ever made the mistake of saving an HTML document in Word? Not pretty. I spent the better part of a day undoing the damage of that mistake. And with AJAX becoming more prevalent all the time, having to branch my handling code is ridiculous:

function doAjax()
{
   var httpReq;

   ...

   if(window.ActiveXObject)
   {
      httpReq = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else
   {
      httpReq = new XMLHttpRequest();
   }

   ...

   if(navigator.appName == "Microsoft Internet Explorer")
   {
      httpReq.onreadystatechange = handleAjaxResponse;
   }
   else
   {
      httpReq.onreadystatechange = handleAjaxResponse();
   }
}

Two salient points from the much-snipped snippet above:
  1. If you instantiate an AJAX request object, IE should be able to figure out that it's supposed to be an ActiveX object under the hood. Honestly--now no-brainer is that???
  2. "handleAjaxResponse" is a function call. Functions use parentheses. Variables don't. Normally, it's a bad thing when Marketing involves itself in software design, but anyone from Marketing should be able to tell you that you mess with customers' expectations of "correct" behavior at your peril. And developers are customers. Something--as I've previously kvetched--Microsoft seems to have forgotten quite some time ago.
And for companies that bring in bling on a Microsoft scale, I think that developers have a right to expect better. And because every right carries a responsibility, they also have the obligation to insist on it. Mind you, wallets normally count more than feet, but if feet are all you have, sooner or later the vendors will pay attention.

Perhaps a bit too much expectation of noblesse oblige from the 800-lb gorilla of the software world. But companies can expect to manage their clients' expectations only so much. The way I see it, Microsoft's slowly waking up to the position that the Republican Party's in right now. Both are already behind schedule for the soul-searching and reformation that will stop their base from hemorrhaging.

Also, in my opinion, Mr. Spolsky's missing a chunk of the point. This is not all about the browser and whether or not it should be the martinet of web code. Browsers can be forgiving, but the toolsets should most definitely not be. Honestly, how many people are coding in Notepad anymore? Even on the Windows platform, a WYSIWYG editor like Amaya is free. As is the web-based editor with which I'm composing this post. 'Nuff said.

We certainly can't change the past, but we can insist on a better future. True, web pages can hang around for quite awhile, but sooner or later they will be updated for reasons other than browser optimization. If the tools are in place to make them standards-compliant, sooner or later the underlying code will hew more closely to the standards.

Will we then pass into a merry world for developers and their users? Of course not. In fact, humankind regresses when it insists on perfection--better to be good than holy, after all. But I see no reason to assume that the future is the Balkanization of the web among browsers (and their "interpretations" of the standards). Any more than I believe in some sort of Highlander-esque "There can be only one" mentality. Or even a return to a Godzilla vs. Mothra slugfest between the two biggest players.

The bottom line is that there is a real cost to this Balkanization (of which the code snippet above is not even a mere whiff, much less a taste), and that customers will take out their frustrations on developers who make life difficult for their browsers, and developers will in turn take it out on the makers of those browsers.

And the makers of tools to write HTML/JavaScript/AJAX/Flash/Silverlight/TheNextNewThing.

And the people who publish the books on those subjects.

And the trade publications that hype the technologies/platforms.

You get the idea. There's far more at stake than just IE8 and which faction eventually wins at Microsoft.

But for all my carping criticism, the Joel on Software post is still well worth your time and brain's CPU cycles. If you've slogged through my opinionated naysaying, you certainly have time for "Martian Headsets." Assuming you haven't already done so: Go ye forth and read!