3 ms·
JSON has an advantage of not having significant whitespace: a bit more verbose with the { and [, but I'd argue it is more robust for complex configuration. YAM
by fomojola 9y ago
JSON has an advantage of not having significant whitespace: a bit more verbose with the { and [, but I'd argue it is more robust for complex configuration.
YAML feels to me like the creation of a person who has never fought with a makefile that imported another makefile that had an extra tab on line 9432: not quite true hell, but a few hours of trying to figure out WHY things aren't working right you would be hard pressed to tell the difference.
- torrent-of-ions 9y agoHow is "no whitespace" an advantage for a human readable file format? You could write JSON with zero whitespace, but you wouldn't because whitespace is absolutely necessary for human comprehensibility.
- fragmede 9y agoBecause humans make stupid accidental mistakes. YAML says there's a world of difference between - flag1 - option2 and -flag1 -option2 but for a human who just wants their thing to work, that's inscrutable, but in JSON, they become [ "flag1", "config2" ] and "-flag1 -config2" respectively. Personally, live python as config is my preference, followed by YAML because comments, but YAML isn't perfect. If the options are right next to each other it's clear there's a misalignment: - option1 -option2 won't work, but - option1 # if there is a huge explanatory # multi-line comment # as is sometimes seen in config # files, sometimes it can be hard # to see the misalignment. - option2
- fomojola 9y agoAs @rockostrich and @fragmede pointed out, I'm talking about whitespace having parsing impact ("significant whitespace"), not just any whitespace. The fact that extra spaces changes the structure of the output seems like a total minefield to me, unless your config is being machine generated (in which case there are many more robust formats to choose).
- jorvi 9y agoNo significant whitespace you say? Take a peek at this: https://paste.ofcode.org/n9q3dnDcPDK5KLex54z6uw https://paste.ofcode.org/n9q3dnDcPDK5KLex54z6uw
- rockostrich 9y agoBy "significant", fomojola meant whitespace does not affect parsing. That JSON you linked to could be minified into a single line with 0 whitespace and still be parsed.