The appeal of XML

April 11, 2008

For a long time, I was not at all fond of XML. The grandiose claims of universal document exchanges, universal editors, and so on were clearly bogus; as lots of people said, understanding the syntax gives you no clue about the semantics. It all smelled of hype and overselling, with XML the latest in a long line of next big things for the enterprisey market.

Then it struck me one day:

XML is a great way to not write a parser.

If you need to write and then read back some data, you need to parse your file format (and to generate it). But parsers are a solved problem; unless you have unusual needs, writing a parser (and its inverse, a generator) is tedious and boring, a necessary expense that you slog through in order to get your program to save and load data.

XML handles the low level parsing and generating for you. You still have to serialize and deserialize your data, but you'd have to do that anyways (even if the deserialization was hidden in parser actions and so on).

(XML also gets you out of having to design an actual file format, although you still have to come up with the serialization and so on.)

This has made XML a lot more attractive to me, to the point where I can imagine using it in my own programs if I need a save format for something.

(Of course, you get the same benefits from any widely supported and reasonably flexible format. These days JSON probably qualifies, and it's a good match for the native data structures in things like Python and Ruby.)

Written on 11 April 2008.
« When I do and don't read a blog's comments
Different reasons for having comments »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Apr 11 23:55:43 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.