27 points · by raganwald · 18y ago · 14 comments
The OP link, however, was pointing out that while this is true, it's also true that XML is a very bad choice for that metadata format. Look at things like JSON or YAML for saner, simpler and more readable alternatives. We ended up with XML because it looked like HTML at a time where "web stuff" was all the rage, not because of its inherent value.
1. Whipping up a web interface for editing the values in the files is trivial
2. If the customer or a less computer-savvy rep needs to tweak the files manually, we can tell them to use XML Notepad to minimize the risk of clobbering something.
I found that by using one layer of nodes and putting the data in attributes instead of their own nodes, the structure is roughly equivalent to INI or Apache config files, and not much more verbose. Maybe it's the Python in my blood speaking, but I appreciate having one obvious solution to a recurring, mundane problem -- organizing and storing small amounts of simple data in a way that anyone can retrieve it.
If the format gets unwieldly that you require special software then the benefit of it being a human-readable text format is lost.
I didn't want to go on a tangent, but the problem is that vanilla Windows XP (not sure about Vista) does not make it safe to play with plain text files, especially those meant for a Linux system. Notepad is not safe. So to protect the unaware, we need another layer between the user and the raw data to make . Any format would be fine, as long as there's a free tool available that the customer and their paranoid IT support would both be comfortable with, which preferably might already be installed, and Windows knows not to open it with Notepad by default. Since other products on the same network already use XML, the customer is OK with staring at this format, expects that .xml files will pop up read-only in Internet Explorer, and knows that the angled brackets mean serious business.
If any other format met all these needs at once, I'd jump for it -- but I haven't seen anything else that does. Any suggestions for other formats that work well on both Windows and Unix?
The same happened with OO. It has uses but it is generally overused.
No, not really
How many times do people actually read XML data, or configuration files? Once in a while I suppose, when performing some configuration tasks, or debugging some data operation. But 99% of the time, your programs are the ones reading the XML. And this is exactly what XML is designed for - being easy for machines to read.
XML is easy to parse, because you have hundreds of available XMl parsers. In many languages you don't even need XML parsers, they're included in the language (actionscript and scala come to mind). It's easy to query with xpath, it's easy to validate with xsd. Most databases can store it natively. There's a whole ecosystem of xml tools that help you work with the data. It would be hard to trade all that for something slightly more readable.
If you're not reading your XML, you're probably using it wrong. And even if you personally don't care, we're still at the mercy of all the developer out there specifying their configuration formats in XML. If you're not reading your configuration files, you're definitely using them wrong.
XML knows nothing about the structure of your data. This is intended, but it means that you have to describe the structure of the data along with the data. Seeing as the software that is going to use the XML has to know about the stucture anyway,if it is going to do anything useful, this just means that you end up specifying the structure in the software and in the XML. Blech!
Go and read up on what yacc and all of its decendants can do for you. It'll open up worlds for you :-)
I've found it easiest to deal with xml in a very focused way. In my case, I always define a schema and use a code generator to get things in/out of memory. From there on, I don't care about the xml anymore. This is fast and reliable. The only real downsides are (a) ugly xml syntax, and (b) having to remember how XSD works every time.
Where I really object to XML is as an internal construct in a system. It's useful for putting things on disk, and it's useful for interchange with damn near anybody because of the ubiquitous libraries. But you don't want to be keeping your core application state in a DOM. Or using it as an inter-component interface. I've seen more than one person do that, and it made me very sad.
In some cases, the trade-off between larger data streams and semantic descriptiveness is not compelling.