Wednesday, January 10, 2007

This Funny JSON vs XML Debate

Fascinating. Amusing, even.

I haven't blogged a technical entry in quite awhile, mostly because I've just been too busy with things like getting married last year. But I got back from my New Year's holiday and found myself in a fun IM conversation with an old co-worker about something new called E4X. My reaction was: "That's daft. Why are you parsing XML in the browser?"

As I was catching up on Ajaxian, I discovered that this debate heated up over the holidays. Apparently Dave Winer, a respected name in the XML community, recently discovered JSON, and was shocked. He went on a rant about reinventing the wheel, the importance of interoperability, and made a casual poke or two at the Silicon Valley engineering culture. He even threatened to string up our friend Doug Crockford.

Hillarious.

I spent several years at two different Silicon Valley companies building XML architectures and XSL presentation tiers. I spent most of that time in a standing debate with one anti-Silicon-Valley academic-type friend, whose argument was: "I would forgive XML all its sins if it was either (a) easy to read, or (b) easy to parse. It's the worst of *all* worlds." He often made casual pokes about the Silicon Valley engineering culture. He even threatened to shoot all the XML guys.

Fortunately, the Ajaxian folks have a good handle on this. But it is fun to see these two communities suddenly clashing. They're both very much a part of the Silicon Valley culture.

XML solves a particular business problem better than anything before. Companies that were aggregating incompatible IT systems in the 80's and 90's were screaming for some WD-40 to lube the joints, especially during Web 1.x. After a decade of bickering over IDL, CORBA, OLE, and Microsoft pulling out of the OMG, the enterprise finally agreed to use a common syntax to build their proprietary data formats on top of. Progress was made. I sound sarcastic, but I'm being serious: Business software over the last 30 years is such an exercise in how *not* to engineer software that it actually took something as bloated as XML, with all its CDATA and character-entity weirdnesses, to patch a pretty bad thing. XML was a huge leap forward.

So Dave Winer is correct to be concerned about interoperability, but he missed the Web 2.0 memo.

We're sending JSON data to the *browsers* because it's a helluva lot easier to use given the (lack of) default Javascript libraries we have running in the browsers. Sometimes we send XHTML (an XML language!) if we're just sending document content.

We're not using our *browsers* as a service aggregators (much, yet) because XmlHttpRequest doesn't let us hit 3rd-party services, and XML is today's primary data format for 3rd-party web services. We might use JSON more over time, since there is a hack to get at 3rd-party services that return JSON, but SOAP and RSS are here for the long-term, so we all have our nifty XML parsers running on our servers anyway. Never mind the fact that web pages that have to hit servers we don't own are a lot less reliable. Anyone who has integrated with 3rd-party ad servers or metric trackers has their own nightmare stories.

And there ya have it.

To Douglas Crockford: Thanks for your PR spin on Javascript literal object syntax. It totally needed a better name, and JSON fits. Now, in the age of asynchronous programming in the browsers, can you help us put a PR spin on "lamda closures" that will make them less scary? They really need to feel friendlier.

No comments: