They invented XML for a reason… So why doesn’t anybody use it? eXtensible Markup Language is the perfect format for storing configuration files and settings for many different reasons. Most obviously, it’s very clear and straight-forward. There are no two-ways about any piece of information or data. You get what you want, when you need it.
The .NET Framework does things right here, storing per-application settings in “.config” files in the user and/or the application directory that have the settings listed in valid XML data which nest correctly and can be easily accessed via an auto-parser in the application itself. Linux now uses XML files for many of its configuration (well, not XML per-say since they don’t use a recognized top-level namespace, but the XML hierarchical structure is there alright). So why can’t Windows just cut to the chase and make the switch – only good can come of it!
The registry may be a nice “hierarchical” place to store bits and pieces of data… but the problem is that it is prone to corruption and conflict because of the way the API is designed. The registry API doesn’t enforce strict hierarchical data access for read and write, so many times things go haywire. Like Windows Explorer for example. Fellow blogger Kristan Kenney has just posted (yet another) bug in Windows Vista that ends up with Windows Explorer thinking every single folder on your hard drive is a photo album — and displaying the files as such!
While Kris has a solution (and a nifty automated patcher) for this behavior, it doesn’t address the root cause: improper access to settings storages causes loss of data integrity and can cause some rather unwanted behavior. The registry is great for storing little tidbits of info, from a list of installed programs to the background wallpaper you are using, but it’s a total failure for anyone looking to do some serious constant read/write operations back and forth because its simply not suited for such a purpose as anyone who uses Windows can testify.
Since XML files can do everything the registry can (except compact all those bits of data into single clusters – but then again, if you use a real filesystem like ReiserFS, cluster sizes don’t matter any way!), why not switch to XML? Why does Windows insist on doing all of these sensitive, fragile, and easily corrupted operations in the registry when they can be done in a much more reliable, hands-on, cleaner, and safer implementation via XML data files? Microsoft obviously knows the merit, using and recommending XML themselves over raw Registry access in the .NET Framework, yet they won’t make the leap where it matters – in the OS itself… Imagine the trouble it would save!