9 ms·
With YAML I can never remember what's an object versus a list, string, or number, nor am I ever able to add new stuff to a YAML file and get it to parse correct
by Alex3917 8y ago
With YAML I can never remember what's an object versus a list, string, or number, nor am I ever able to add new stuff to a YAML file and get it to parse correctly without first looking up the spec. And it's impossible to see where large objects start and end.
In contrast, JSON is super intuitive and basically self documenting. The only real quirks are that you need to use double quotes, and objects can't have a trailing comma.
The only good thing I can see about YAML is that it's super easy to convert and re-export to JSON.
- dagw 8y agoIn contrast, JSON is super intuitive and basically self documenting. Personally I've found the exact opposite when dealing with 'normal' people. Most people can get basic YAML, but unless they're a programmers (or at least know how to program) most people fail miserably at writing JSON by hand.
- twodave 8y agoI agree with this. Our biz guys have to edit JSON config files regularly, and they're limited to basically just copying/pasting lines from existing files and editing the values. When they need to be able to do more, we end up building a UI for it and either storing the config elsewhere or writing the code to manage persisting their changes to the config.
- emodendroket 8y agoSee how much fun these people have trying to figure out why their application crashes because they put a tab instead of spaces into the YAML file.
- deleted 8y ago[deleted]
- arbie 8y agoWe use a YAML linter before attempting to load the file. Provides detailed feedback to the user: "Tab found at line 17, column 23" Also detects repeated hash keys. This is a very good compromise between user-friendliness and machine-friendly specification and serialization. Thank you very much for YAML! It is a critical user-interceptable interchange mechanism at several companies that I have worked at.
- XorNot 8y agoJSON has too many rules regarding comma placement.
- dorfsmay 8y agoYou use JavaScript a lot more than python, right? Intuitive usually means "close to what I'm used to".
- Alex3917 8y agoI actually use Python a lot more than Javascript. That's why the double quotes and the no trailing comma are always what get me. Especially since leaving the trailing comma is considered the best practice in every other language.
- weberc2 8y agoJS added support for a trailing comma, and single-vs-double quote is a contentious topic in Python land!
- pphysch 8y agoPython dicts are a lot closer to JSON than YAML. The real schism here, IMO, is Programmer Intuitive vs. Natural Language Intuitive.
- geoalchimista 8y agoSecond this. I have used Python dict to write the default config file and JSON Schema to validate a user-supplied config file, which worked quite well in regard of that purpose.
- dokem 8y agoPython objects and JSON are practically identical.
- weberc2 8y agoIn what sense could this be true? Python objects support a whole host of behavior; JSON is a data format. Python dicts might be a closer analogy except Python keys can be anything that is hashable while JSON requires strings, and of course Python dict values can be any Python value; not just the JSON analogs.
- xellisx 8y agohttps://json5.org/ https://json5.org/
- mrybczyn 8y agoLOL https://xkcd.com/927/ https://xkcd.com/927/
- mschuster91 8y ago> In contrast, JSON is super intuitive and basically self documenting. The only real quirks are that you need to use double quotes, and objects can't have a trailing comma. I'd expand the list of quirks... JSON lacks comments (both line-level and block level). Fine for data transport but super super bad for configuration files.
- lostctown 8y agoThis hits home. Every time I've ever had to make the decision I've chosen yaml, for exactly this reason. Funny how the seemingly small things can be absolute show stoppers when it comes to making decisions in production.
- twodave 8y agoIn our JSON config files we do: { "ConfigKeyComment": "This is for blah blah blah", "ConfigKey": "Foo" } Obviously this wouldn't work in all cases (you're putting more work on your parser to interpret unused keys basically), but if we're talking config files specifically, I see this as an acceptable approach since there's little chance you'll be parsing such files more than once each (plus, writing a simple tool to strip the comments out would be very trivial).
- biztos 8y agoI've tried something similar but found it way too painful if the comments need to be long... # Never enable this config, because if you do the space-time # continuum will collapse into itself and the cloud servers # will disappear in a puff of steam. However, if you really # must enable it, remember that it's boolean and go read # TICKET-8675309 for the extensive list of side effects. TurboFactorRenoberation = false ...so people just end up writing stuff like: { "ConfigKeyComment": "TICKET-8675309", "ConfigKey": "TurboFactorRenoberation", "ConfigVal": false } [edit]: formatting
- mschuster91 8y agoThat's not JSON anymore, that's pretty much enough to be considered a unique DSL. Scary that this is more or less required.
- sho 8y ago> objects can't have a trailing comma This has caused me so much misery in the past, especially since none of the tools will tell you which line the offending comma is on. Great, somewhere in my thousand-plus-line JSON file is a tiny syntax error but you won't tell me where. Ended up having to regex for them. Didn't do wonders for my trust in JS tooling.