Tuesday, October 16, 2007

I love XML


It seems the general response about XML among programmers is always a groan or disgust, just like how text based editor lovers (vi,emacs) react about IDEs.

And I still admit, now openly, that I love XML. And why is that? because it's text and a buzzword. Yeah I'd love it a little more if my adored JSON would've become a similar buzz word, but it happened to be XML since it had the W3C's name behind it.

And what's so good about it? specially about buzzwords? first let me recognize that buzzwords are something that can cause a lot of hot air masses moving around corporations, but let's be frank, if we'd take buzz words from the kind of managers that like them, they'd still find another way to be useless, it's not the word's fault.

Anyhow I recognize XML has been abused, I do NOT see XML as a database killer, I see it as a message passing form, and as a configuration form (and configurations can take many forms like a document expressed in XML).

Well what I love from XML is that it is human readable, AND strictly defined enough to be safely computer readable. True it might not always be the easiest to parse XML in code, and XPaths can be hard for the non lovers (it's close enough to regular expressions that I actually like XPath some). But it is both computer and human readable. Which means I can write my programs to interconnect via XML, and if I want or need to check that they're interconnecting correctly, or to issue a specific order by hand, I can review or create XML to do this with no special tools other than an editor and my brain. As both a sysadmin and programmer I've found myself in emergency situations where all I had was a shell with all missing commands but an old vi and a few calls, so one gets used to try and work with environments and technologies that require the least amount of components possible in case something goes wrong.

So I prefer a file format I can check or throw together quickly with an editor.

And why a buzzword? why I would've been happier if JSON had become the buzzword (it IS less verbose than xml and still very readable for programmers.), well that's because when something becomes a buzzword, everybody suddenly HAS to implement it, they need to use it. And in this case, this has brought forward incredible things, like XML-RPC... and wether you like XML-RPC or not, you have to admit we have a level of interoperability between vendors and programs that we never had before XML.

Today, no matter how antagonist a company is about integrating with others, or with another company, or how oblivious they are about letting people stick things to interoperate with their code, if they support a decent XML communication system (be it via files, pipes, commands, databases, etc) then integration is at worst a complex XST away. It's possible with a DTD or simple reverse engineering on the XML file, to work with a program with which it wasn't possible to work before without a clunky API or worse, having to pay for the API's spec, or worse yet, the program was APIless.

So what I say is, XML is a great tool for the hackers, and since I am a hacker at soul, I try to use or support technologies who help people like me, and that is the high value of XML to me, a guy without a penny or a few bucks for his own project or his companu's project now can push and pull data in and out of large and diverse applications and systems where he had no luck or possibility before.

P.s. As I said, I like JSON's syntax better, it's still programmer readable, and it's much less verbose than XML, the sad part is that it's not a buzzword and thus not so universal.

And, for my Rails and Ruby friends, I say JSON and not YAML because I do not like that easily visible structural delimitators in YAML are optional. I think that leads to troubles trying to identify a failure point. I like visually striking block delimiters like JSON's curly braces.

1 comment:

ReinH said...

"I do NOT see XML as a database killer, I see it as a message passing form, and as a configuration form..." Amen. The primary function of any interface is to communicate, the secondary function is to enable interaction. XML is at heart a machine interface (as REST, SOAP, XML-RPC, and countless XML configuration schemas show) and it meets both criteria for a successful interface. REST is one of the most important web developments to date and it's main messaging format is XML.

That said, I also agree that json is superior on almost all accounts. Expecially when it comes to asynchronous HTTP requests (Think AJAJ, not AJAX; think JSONRequest, not XHR), where communicating with a javascript client via a javascript-native object serialization notation seems like a no-brainer. It also works for REST, as the del.icio.us JSON web service shows, and indeed the same RESTful interface can drive both. But that's another post entirely.