If YAML ain't markup language, what is it?

YamlMarkup

Yaml Problem Overview


I fail to see what makes YAML any less of a markup language than XML. The purpose of a markup language is to define the structure of a document, and YAML does exactly that (YAML stands for YAML ain't markup language).

What YAML should instead stand for is, Yet another markup language.

Yaml Solutions


Solution 1 - Yaml

Here's the real story... :)

Clark, Oren and I started working on YAML in April 2001. Oren and Clark were part of the SML mailing list, which was trying to make XML simpler. I had just written a data serialization language for Perl called Data::Denter. Clark contacted me to tell me about an idea they had called YAML, which looked similar to Data::Denter syntax. Clark already had acquired yaml.org.

After a few months of us working together, I pointed out that YAML (which most definitely stood for Yet Another Markup Language at that time) was not really a markup language (marking up various elements of a text document) but a serialization language (textual representation of typed/cyclical data graphs). We all liked the name YAML, so we backronymed it to mean YAML Ain't Markup Language.

http://yaml.org/spec/ starts with:

> YAML™ (rhymes with “camel”) is a human-friendly, cross language, Unicode based data serialization language designed around the common native data structures of agile programming languages.

I couldn't have said it better myself… :

Solution 2 - Yaml

So, a markup language presumes a base text, typically human readable, and then special indicators or "markup" which direct processing. The idea comes from an editor, who would take a printed-version of someone's manuscript, and "mark it up" to show where new lines should go, edits, etc.

In this manner, SGML is a meta-language for declaring markup languages, and HTML is a markup language. In 1996-7, when XML came on the scene, it was sold as a simplified SGML meta-language for creating markup languages. In XML (and SGML), you have elements to "mark" a portion of text, and then attributes that modify the marking. Over time, XML was used for much more than document markup though, people used it for data serialization -- even though it was never designed to do such a thing. Of course, it was the big problem to be solved.

YAML and JSON appeared on the scene and focused on data serialization, not document markup. In these languages, there simply isn't a core document text.
Hence, YAML Ain't Markup Language is quite an accurate differentiator from XML.

Solution 3 - Yaml

XML inherited the "ML" part of its name from HTML and SGML, which are "markup" languages in that what they describe is a stream of plain text together with markup instructions such as "this piece of the text should be bold" or "this piece of the text is a heading". That is, those particular parts of the text are marked up as being bold, or a heading.

Later, some people took to writing XML that consisted only of tags and attributes, with no plain text for those tags to mark up. (Opinions and styles differ as to whether that is an appropriate use of XML). When used that way, XML becomes a language for writing down tree-structured data.

YAML is "not a" markup language because its data model contains only the tree structure, with no notion of an underlying linear text that the tree structure applies to. There's nothing to mark up there -- or put differently, the data represented by a YAML stream is not markup. In contrast, the data represented by an XML tag is markup, or at least according to some points of view is supposed to be. (In both cases, the representation of said data contains some markup, such as colons and indentations in YAML or '=' and quotes in XML, but that is not the point).

Solution 4 - Yaml

Here's a quote from a page about YAML:

> I suppose the very first question on readers' minds has to be, "why > the name YAML?" There are a number of tools that have cutely adopted > acronyms of the form "YA*", to mean "Yet Another XXX." In the arms > race of open-source wit, YAML eschews its implied acronym, instead > settling on the recursive "YAML Ain't Markup Language." There is a > certain sense to this, however: YAML does what markup languages do, > but without requiring any, well, markup.

The name was chosen because it requires much less markup than other than other traditional languages, such as XML. It distinguishes it as more data-oriented rather than markup-oriented.

Solution 5 - Yaml

> I fail to see what makes YAML any less of a markup language than XML.

There are a few advantages of using YAML instead of XML. First of all, it is a more human-readable. Not like XML data structure, we have to define and give tag name of each data elements. Developers would feel bulky for the XML code and users are quite hard to understand the XML documents. Actually, XML is for machine to machine communication, not for users-machine communication. Since YAML is kindly human-readable, you can treat it for users to read/change data source and used it to communicate with computer program.

Here is an example showing how's their structures are different.

XML Examples:
<busNo>101
    <busStop>ABC
           <busFee>5.4</busFee>
    </busStop>
    <busStop>CUHK
           <busFee>5.4</busFee>
    </busStop>
    <busStop>HKU
           <busFee>5.4</busFee>
    </busStop>
    <busStop>XYZ
           <busFee>5.4</busFee>
    </busStop>
</busNo>

YAML Examples:
--- #bus no
101  : [ABC:5.4, HKU:5.4, CUHK:5.4, XYZ:5.4]

The best example to use YAML is used for configuration file of the program. Certainly, you can parse your own format of configuration file into XML and pass it into your program. But, you can use YAML instead. Also, you could have faster development, especially on web development. YAML is designed with scripting languages such as Python, Perl, Ruby.etc. YAML is designed to translate easily to strucutres which are common to various languages stated above.

In conclusion, YAML is designed for human-read, which make less of a markup language than XML.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondesbestView Question on Stackoverflow
Solution 1 - YamlingydotnetView Answer on Stackoverflow
Solution 2 - YamlclarkevansView Answer on Stackoverflow
Solution 3 - Yamlhmakholm left over MonicaView Answer on Stackoverflow
Solution 4 - YamlEdoDodoView Answer on Stackoverflow
Solution 5 - YamlTheOneTeamView Answer on Stackoverflow