August 16, 2003

XML Configuration Files: A Step Backwards?

Is XML a good format for configuration files?

I think the answer depends on how the configuration file is supposed to be used. If the config file will be maintained by a UI tool, then XML may be okay. However, if the config file will be maintained by an administrator using a text editor, then I think the rush to use XML is a step backwards in terms of usability.

What's the argument that is made in favor of using XML as a config file format? Usually, it's "there are lots of XML parsers available," which is actually not an argument acceptable to anyone who cares about usability. It's an argument that says "our developers will have to do less work to parse the config file." This is classic: decisions are made on the basis of what is easier for developers.

Anyone care to make the argument that XML is a readable format? Maybe it is, or maybe it isn't. The use of namespaces certainly makes the XML less readable. And it's not an argument over whether XML is readable or not, as if it's a yes/no question. The real question is "is XML more readable that format X?" for some alternative format X. Frankly, I think that Microsoft's .INI file format is more readable. (Note: I don't know where this config file format originated. Please don't make a big issue over my calling it "Microsoft's .INI file format.")

The .INI file format uses sections set off with titles in square brackets. Within each section, there are name/value pairs, with an equals sign separating the name and value. It's a marvelously readable config file format compared to XML! Some people make the argument that XML permits more structure. I don't agree with that. In the .INI file format, structure is created by having a value refer to another section. That way, a config file can have a tree structure, with a parent section having one or more child sections. I will admit that it's probably easier to create a hierarchical configuration using XML than .INI, but I don't see that many application config files that require a lot of hierarchy. And the .INI file format permits reuse of a node in ways that would be more difficult with XML. Suppose I want to define a bunch of default values -- let's call it a "profile" -- and use that set of defaults in several other sections. In the .INI file format, I just add a name/value pair to those other sections with the value refering to the section that contains the defaults. To do this with XML would require using XPath. It could be done, but it's a little more convoluted.

XML may be good for some file formats, including some config file formats. Any good designer, I'm sure, will choose a format based on the specific requirements of the application, and there can be no one-size-fits-all format. But I do hope that designers will put users needs over developers needs.

Posted by Doug Sauder at August 16, 2003 01:46 PM