EDIT from 2019: Hi folks. I wrote this gist for myself and some friends, and it seems like it's gotten posted somewhere that's generated some (ahem, heated) discussion. The whitespace was correct when it was posted, and since then GitHub changed how it formats (thank you @anzdaddy for suggesting a formatting workaround) honestly this is a random throwaway gist from 2015, and someone more knowledgable about this comparison should just write a proper blog post about it. If you comment here I'll hopefully see it and stick a link to it up here. Cheers. @oconnor663<pre>
tags. Look at the raw text if you care about this. I'm sure someone could tell me how to fix it, but
Here's the canonical TOML example from the TOML README, and a YAML version of the same.
title = "TOML Example" [owner] name = "Tom Preston-Werner" dob = 1979-05-27T07:32:00-08:00 [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" [clients] data = [ ["gamma", "delta"], [1, 2] ] hosts = [ "alpha", "omega" ] |
title: YAML Example owner: name: Tom Preston-Werner dob: 1979-05-27T07:32:00-08:00 database: server: 192.168.1.1 ports: [ 8001, 8001, 8002 ] connection_max: 5000 enabled: true servers: alpha: ip: 10.0.0.1 dc: eqdc10 beta: ip: 10.0.0.2 dc: eqdc10 clients: data: [ [gamma, delta], [1, 2] ] hosts: - alpha - omega |
Is this a troll or is the OP a moron? Does he not realize that the "yaml" sample he's comparing to is entirely invalid, as has been pointed out multiple times, and as has been corrected in a fork of his gist? Any person with the slightest sense of rigor (or even self worth) would have fixed up the samples to actually permit an honest comparison by reasonable people, rather than intentionally skewing things as they have. If I were walking in the door, with no knowledge of either format, and saw the two (dishonest) snippets above, it's likely I would choose the first as well. But let's say, instead, that the first looked like this:
Which would you pick now? Sure, you'll complain this is intentionally mal-formatted, and very likely invalid TOML to boot, but what is presented as YAML is precisely that - intentionally (or worse, unintentionally at first but lazily NOT fixed when the error is pointed out) broken, as well as functionally invalid, YAML.
Be fair to your readers -- and avoid making yourself look like a tool in the process -- by presenting FAIR comparisons if you're going to bother to post such things at all...