4 ms·
YAML's not bad if you couple it with strong types. I used YAML _heavily_ and wasn't aware of any of the issues that the author mentioned because of the types.
by rdw 5y ago
YAML's not bad if you couple it with strong types. I used YAML _heavily_ and wasn't aware of any of the issues that the author mentioned because of the types. It doesn't let YAML automatically parse dates because the destination structure is either a date or a string or whatever, and that controls the parsing. It doesn't have the Norway problem because it knows whether a field is a boolean or not. I don't think it had the octal problem, not 100% sure though.
It's very good for non-technical people to edit because they are allergic to symbols and quotes and brackets and making sure things match. YAML's syntax let you write like you're a CEO sending agenda notes to a subordinate. You can easily switch between line-per-item and brackets-style and you do so whenever the readability is improved by doing so. It's highly intuitive somehow. You can pretty much turn someone into a config-editor just by showing them an example file, especially with syntax highlighting.
- zeroimpl 5y agoSounds like you are using a specialized parser. At that point, it’s not YAML.
- rdw 5y agoIt used an off-the-shelf library, I don't remember which one anymore. I don't think it really matters though -- YAML is a format, not a parser. Per the YAML docs [0], "Creating a fully compliant parser has proven almost impossible." Pretty much every YAML parser out there is going to have its own idiosyncratic subset that it handles. That doesn't make the _files_ not-YAML. (This does make YAML a horrible data exchange format. No argument there!) Also, JSON has a similar condition [1]. [0]: https://github.com/yaml/yaml-grammar https://github.com/yaml/yaml-grammar [1]: http://seriot.ch/projects/parsing_json.html http://seriot.ch/projects/parsing_json.html
- UI_at_80x24 5y ago>It's very good for non-technical people to edit I strongly disagree. Being whitespace sensitive it's stupidly bad for non-technical people. I don't like YAML for several reasons, to be honest I'd prefer an .ini based config setup or BSD styled "option=variable" config file paradigm. But I hate/despise/loathe the fact that YAML files are whitespace sensitive. That's a horrible choice. I hate python for it too, and avoid it's use whenever possible.
- rdw 5y agoMaybe my people were special in some way, but it seemed like the idea of lining things up vertically just immediately clicked with them. It seems like it's something that folks do in their regular lives when writing (hand-written) notes or on a whiteboard. People have strange trouble with delimeters. They put commas inside the closing quote, (e.g. ["hello," "there"]) because I guess that's how they were taught in English class somehow. They forget a bracket and then can't figure out how to fix it because the tools are no help. They start putting in excess braces like they're some type of Simon Says: [{"hello"}]. I guess I can't be critical -- this is a lot like how I write CSS. But whitespace makes more sense to a lot of folks because it just "looks right". TOML is a decent format because it does use whitespace for delimiting -- but only newlines. It gets verbose if you want to represent large amounts of deeply-nested data, though.