Since XML is relatively well known in the .NET community, it's likely a lot of readers will want to understand why you might want to choose one over the other, so lets get started with a comparative example. Here's some sample data:
  • YAML is easily readable by humans.
  • YAML is consise and compact.
  • YAML is expressive and extensible.
  • YAML ain't markup language!

A YAML version of this list looks like this:

- YAML is easily readable by humans.
- YAML is consise and compact.
- YAML is expressive and extensible.
- YAML ain't markup language!

Readability and consiseness

YAML is easy to read, at least partially because of it's conciseness. The example, which looks much like the bulleted list, illustrates how YAML leverages existing typographic conventions to structure information. The only characters present other than the text are the hyphens used to introduce new items in the list. In YAML, these hyphens are called indicators, please imagine that those hypens were colored blue.

Let's compare this with the same list in XML:
<ul>
    <li>YAML is easily readable by humans.</li>
    <li>YAML is consise and compact.</li>
    <li>YAML is expressive and extensible.</li>
    <li>YAML ain't markup language!</li>
</ul>
In the XML there are substantially more blue characters, plus I had to choose element names shown in red. I chose names based on an XML application called XHTML, here's a full example in in XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>A list of YAML attributes</title>
    </head>
    <body>
        <ul>
            <li>YAML is easily readable by humans.</li>
            <li>YAML is consise and compact.</li>
            <li>YAML is expressive and extensible.</li>
            <li>YAML ain't markup language!</li>
        </ul>
    </body>
</html>

As you can see, the XML based version is growing harder to read because the volume of tag-based markup is beginning to obscure the content. Sure it looks nice in a browser or WYSIWYG editor, but even for this purpose, HTML is seeing some competition from the "wiki" languages, which reduce the number of "markup language" characters to a bare minimum like YAML

Last edited Jan 19, 2009 at 8:27 PM by BurtHarris, version 2

Comments

No comments yet.