Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Config Files Redux

by Firefly258 (Beadle)
on Nov 24, 2006 at 23:33 UTC ( #585942=note: print w/replies, xml ) Need Help??


in reply to Config Files Redux

oodles of name=value pairs

Just how does XML make the process any simpler? consider this
<xml> <host1> <hostname>foo</hostname> <function>Serve intranet content</function> <transport>TCP</transport> <port>80</port> </host1> </xml>
as opposed to an .INI
[Host1] Hostname=Foo Function="Serve Intranet content" Transport=TCP Port=80
I certainly see the latter as simpler, neater, easier-to-type, consuming-less-space, more legible and less error-prone, etc.

IMO that out-of-the-box an .INI style configuration file is relatively simple to use. The way the format is inherently structured ensures good readability for humans to readily glean information from the contents. Little is likely to go wrong as there is a very neglible amount of markup to get in the way. Writing/using a parser for the format is quite easy and handling exceptions is also straight-forward, there aren't too many exceptions.

XML on the otherhand allows for structured information like nested or heirarchical configuration data. It is well portable and it's a standard, so the data is readily avaialble for any program to use. However, since XML is structured and is dependant on well-formedness, a single mis-punctuation or missing tag can lead to XML being not so forgiving. That coupled with the fact that XML uses a lot more markup (which can and usually does get in the way) doesn't readily produce neat and legible information, atleast from a human perspective.

You can argue that XML might be made to work by neatly laying out the information as per a DTD or by using an XML aware editor, but IMO that writing a DTD is extra work just to get XML to work when there are better, cheaper, easier alternatives, not all editors are clever either. Anyone editing the XML must adhere to and be knowledgeable of the DTD. In cases where the XML is dependant on its meta-data (DTD/XSD/XSLT,etc) which isn't avaialble, everything falls apart.

The .INI style config. file has been around since the beginning of computing, it's simple, legible and for the same reasons, quite popular. There are modules in almost every language to write, manage, maintain, verify, etc .INI files. I'd choose it over XML even if humans rarely had to manage it because there might come a day when a person might have manually make changes, and if that were under stress, I'd like to ensure his job were to on as smootly as possible.

There are also humans to consider

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://585942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2021-10-23 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?