July 2, 2008
@ 01:56 PM

Jeff Atwood recently published two anti-XML rants in his blog entitled XML: The Angle Bracket Tax and Revisiting the XML Angle Bracket Tax. The source of his beef with XML and his recommendations to developers are excerpted below

Everywhere I look, programmers and programming tools seem to have standardized on XML. Configuration files, build scripts, local data storage, code comments, project files, you name it -- if it's stored in a text file and needs to be retrieved and parsed, it's probably XML. I realize that we have to use something to represent reasonably human readable data stored in a text file, but XML sometimes feels an awful lot like using an enormous sledgehammer to drive common household nails.

I'm deeply ambivalent about XML. I'm reminded of this Winston Churchill quote:

It has been said that democracy is the worst form of government except all the others that have been tried.

XML is like democracy. Sometimes it even works. On the other hand, it also means we end up with stuff like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <m:GetLastTradePrice xmlns:m="Some-URI">
      <symbol>DIS</symbol>
    </m:GetLastTradePrice>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

You could do worse than XML. It's a reasonable choice, and if you're going to use XML, then at least learn to use it correctly. But consider:
  1. Should XML be the default choice?
  2. Is XML the simplest possible thing that can work for your intended use?
  3. Do you know what the XML alternatives are?
  4. Wouldn't it be nice to have easily readable, understandable data and configuration files, without all those sharp, pointy angle brackets jabbing you directly in your ever-lovin' eyeballs?

I don't necessarily think XML sucks, but the mindless, blanket application of XML as a dessert topping and a floor wax certainly does. Like all tools, it's a question of how you use it. Please think twice before subjecting yourself, your fellow programmers, and your users to the XML angle bracket tax. <CleverEndQuote>Again.</CleverEndQuote>

The question of if and when to use XML is one I am intimately familiar with given that I spent the first 2.5 years of my professional career at Microsoft working on the XML team as the “face of XML” on MSDN.

My problem with Jeff’s articles is that they take a very narrow view of how to evaluate a technology. No one should argue that XML is the simplest or most efficient technology to satisfy the uses it has been put to today. It isn’t. The value of XML isn’t in its simplicity or its efficiency. It is in the fact that there is a massive ecosystem of knowledge and tools around working with XML.

If I decide to use XML for my data format, I can be sure that my data will be consumable using a variety off-the-shelf tools on practically every platform in use today. In addition, there are a variety of tools for authoring XML, transforming it to HTML or text, parsing it, converting it to objects, mapping it to database schemas, validating it against a schema, and so on. Want to convert my XML config file into a pretty HTML page? I can use XSLT or CSS. Want to validate my XML against a schema? I have my choice of Schematron, Relax NG and XSD. Want to find stuff in my XML document? XPath and XQuery to the rescue. And so on.

No other data format hits a similar sweet spot when it comes to ease of use, popularity and breadth of tool ecosystem.

So the question you really want to ask yourself before taking on the “Angle Bracket Tax” as Jeff Atwood puts it, is whether the benefits of avoiding XML outweigh the costs of giving up the tool ecosystem of XML and the familiarity that practically every developer out there has with the technology? In some cases this might be true such as when deciding whether to go with JSON over XML in AJAX applications (I’ve given two reasons in the past why JSON is a better choice).  On the other hand, I can’t imagine a good reason to want to roll your own data format for office documents or application configuration files as opposed to using XML.

FURTHER READING
  • The XML Litmus Test - Dare Obasanjo provides some simple guidelines for determining when XML is the appropriate technology to use in a software application or architecture design. (6 printed pages)
  • Understanding XML - Learn how the Extensible Markup Language (XML) facilitates universal data access. XML is a plain-text, Unicode-based meta-language: a language for defining markup languages. It is not tied to any programming language, operating system, or software vendor. XML provides access to a plethora of technologies for manipulating, structuring, transforming and querying data. (14 printed pages)

Now Playing: Metallica - The God That Failed


 

Wednesday, 02 July 2008 16:16:02 (GMT Daylight Time, UTC+01:00)
> On the other hand, I can’t imagine a good reason to want to roll your own data format for office documents or application configuration files as opposed to using XML

Why is it that when someone is making a case for XML they always assume the only alternative is "roll your own data format"?

You mentioned JSON for transmitting structured data, but for the more general case of structured information in files, what about YAML, INI files, delimited plain-text files, and even HTML (I've seen cases of using an XML grammar that is nothing more than presentation markup)? These are all common formats that have lots of tools to support them, plus have the benefit of simpler parsers (sans HTML) and a more readable native format.

Sure, there are cases where XML makes sense, but other simpler formats have proven very useful, too. JSON wouldn't be so popular if XML was easier to use. INI files are simple and worked well for Windows apps for years. And most of *nix configuration files have been plain text and work great.

There are many alternatives to XML besides "rolling your own".
Wednesday, 02 July 2008 16:20:40 (GMT Daylight Time, UTC+01:00)
But there is the BIGGEST problem of XML, which it can never do away - It was never meant for humans.

Personally I am using YAML and with ruby one has 0 problems to use YAML.

Yaml is not perfect, the whitespace-matters every now and then forces me to indent the wrong line properly - no big deal, but annoying.

However, compared to XML, I simply can not go back to it. I let ruby autogenerate all the XML stuff I will ever need, and I will in 100 years not maintain any XML on my system.

INI files are ok too, I dont use them but they are 100x more appealing than XML.

BTW I am not so much anti-XML anymore, I just autogenerate it when needed. So it is no big deal for me anyway.

About tools support, I am not sure. I often read complaints about XML parsers and generators and libraries, that they sometimes... well just plain suck.

I think the more complex something gets, the more problems arise.

Keep it simple! I dont think Jeff is alone with his opinion.
markus
Wednesday, 02 July 2008 17:01:47 (GMT Daylight Time, UTC+01:00)
Tend to agree w/Jeff. I think, simply, if what you're storing isn't meant to be portable, use a simpler (non-XML) format. Exporting CMS data, cool. Storing config settings, not so much.
Wednesday, 02 July 2008 18:27:10 (GMT Daylight Time, UTC+01:00)
I'll agree that XML is the best configuration file format, except in an environment where you don't have an XML parser. In .net I not only have an xml parser available, but I have a configuration API that totally abstracts the file format away.

It is true that XML isn't designed to be easy to read by mere mortals, but then again what application developer exposes their raw configuration files to a typical user? Any quality application, especially those meant for non-developers to user will have options dialogs for customizing the application. I challenge anyone to release a product requiring configuration in order to do anything useful to attempt to sell an application to users without an options dialog. You simply won't make any sales.

So with that out of the way... I think that any developer can read an XML configuration file and understand it just as easily if not better than other formats like YAML or INI. let's compare apples to apples shall we!

<appsettings>
<setting1>value1</setting1>
</appsettings>

[appsettings]
setting1=value1

Both are easy to read, XML is just a little more verbose. If you can't read this, then you have major problems.

What about more complicated examples? How to you configure a nested set of configuration properties in INI? I think the following configuration is pretty simple to read. Can you say the same for the same configuration in INI or YAML? If you think so, then show us what it would look like.

<MyCompany>
<ServiceWatcher>
<services>
<service serviceName="service1" serviceMachineName="server1"
outputFileNameToWatch="\\server1\c$\serviceFile.txt"
outputFileMaxAgeMinutes="60" outputFileExpectedAgeMinutes="10"
pollIntervalMinutes="5" logger="server1_service1"/>
<service serviceName="service2" serviceMachineName="server2"
pollIntervalMinutes="5" logger="server2_service2"/>
</services>
</ServiceWatcher>
</MyCompany>

<log4net>
<logger name="server1_service1">
<level value="Debug"/>
<appender-ref ref="RollingLogFileAppender_svc1"/>
</logger>
<logger name="server2_service2">
<level value="Debug"/>
<appender-ref ref="RollingLogFileAppender_svc2"/>
</logger>
<appender name="RollingLogFileAppender_svc1" type="log4net.Appender.RollingFileAppender">
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaximumFileSize" value="50KB"/>
<param name="MaxSizeRollBackups" value="2"/>
<param name="StaticLogFileName" value="true"/>
<param name="File" value="logs\serviceWatcher_svc1.log"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %property{log4net:HostName} [%t] %-5p - %m%n"/>
</layout>
</appender>
<appender name="RollingLogFileAppender_svc2" type="log4net.Appender.RollingFileAppender">
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaximumFileSize" value="50KB"/>
<param name="MaxSizeRollBackups" value="2"/>
<param name="StaticLogFileName" value="true"/>
<param name="File" value="logs\serviceWatcher_svc2.log"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %property{log4net:HostName} [%t] %-5p - %m%n"/>
</layout>
</appender>
</log4net>

The preview of this comment shows that the white space is being removed from my last XML example, but it is being inserted in my first XML and INI example. That will make it harder to read that it normally would. Whitespace in any format INI, XML, or YAML affects readability. Hopefully this is just an issue with the comment preview.
Wednesday, 02 July 2008 20:13:23 (GMT Daylight Time, UTC+01:00)
I'm sorry but I agree with Jeff completely. I worked with a CMS that used only XML to store data, to transform data (XSL), and to create data structures with XML Schemas. I hated it. When I expressed my concern they said "Its just XML" of which I replied "THAT'S THE PROBLEM!" The application was one, so freaking slow and two, you had to program EVERYTHING. Its like someone saying I have a CMS and pointing you to php.net and saying "Its just php; you can do anything."

When I first heard of this CMS, I was like cool XML no problem but the more I coded the more I hated doing the same thing over and over and over and over again. All of which was in XML but woopty fricken do.

XML is a good idea in theory but is rarely the best choice unless you NEED to be portable. And even then I would really think about that decision.

If I decide to use XML for my data format, I can be sure that my data will be consumable using a variety off-the-shelf tools on practically every platform in use today. In addition, there are a variety of tools for authoring XML, transforming it to HTML or text, parsing it, converting it to objects, mapping it to database schemas, validating it against a schema, and so on. Want to convert my XML config file into a pretty HTML page? I can use XSLT or CSS. Want to validate my XML against a schema? I have my choice of Schematron, Relax NG and XSD. Want to find stuff in my XML document? XPath and XQuery to the rescue. And so on.


Yeah because every project needs infinite possibilities and has an infinite budget. Oooh Oooh lets add flexibility for the sake of flexibility. And I think I would have to redefine flexibility just to make that work.

And don't every bring up Office Documents, and even calling that XML. Human readable my...

I hate it when people say use XML because its XML and everyone knows about it. Yeah, lets do whatever you want to do.

Nick
Thursday, 03 July 2008 08:18:17 (GMT Daylight Time, UTC+01:00)
Write enticing titles to pages to attract traffic.



Targeted Internet marketing is about SEO target marketing is not about
getting the most genuine traffic or visitors to your website, but getting
targeted visitors is a time taking job

Google analytics is one system which caters to all of your need regarding
traffic analysis. It is free tool and calculates your bounce rates, traffic
sources, keywords, locations, hits and a lot of other information also.

Always use such keywords or key phrases that are convincing.Peole who are
searching for p[products don't have much time to wait and see every link,
therefore write keywords for what they are exactly looking for.

Write enticing titles to pages to attract traffic.

Comments are closed.