XML Abuse Considered Helpful

I have heard too many complaints from people who don’t grok XML. XML isn’t just a standard data format: t has turned out to be one of those rare technologies which really does add to the basic platform on which we build much of our software. The key is scripting.

Many people react badly to XML. They complain that it is wordy, not particularly human-readable, and overly-complex. They are right. XML is only close to the perfect solution for a narrow range of problems. But it is also a pretty good solution for many more. Above all, it is free: nearly every programming environment comes with XML handling built-in or readily available.

The reason this is so wonderful is that it gives us free parsing. Free parsing isn’t just a neat trick. It’s incredibly, irreplacably useful – right up there with regular expressions, associative arrays, and garbage collection. This because it reduces the cost of one of the most valuable techniques for software development, which I will call toolmaking.

Toolmaking is the principle that the best way to solve a problem is often to write a new language for that class of problem, and then use that language to solve the particular problem at hand. The benefits of this are obvious and proven. It breaks a problem cleanly into two well-understood and well-separated pieces. The results are more maintainable and adaptable.

Toolmaking is is deeply embedded in the Unix tradition, which in the old days involved using yacc and lexx. More recently, Perl has become the engine of choice. Today, I believe, the balance has shifted to XML – not because XML is more powerful (you can do anything with Perl or yacc) or prettier (XML can be dense and incomprehensible) but because it is easier. Toolmaking becomes affordable for a whole new class of problems.

There are two approaches to toolmaking. The first is the data-driven approach, in which the problem is captured in a data format; XML is clearly well suited for this. But some problems don’t fit neatly into the data-driven paradigm. For these, the solution is the second approach: scripting. Here, XML can serve also, although using XML for scripting smacks of abuse. But it has an ally, one which is also free: XSLT, itself an example of just such abuse. Together, XML and XSLT provide the core of a powerful scripting engine which is standard across platforms and languages.

2004-08-26

Comments