Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
YAML's good for config, but if the user don't have to change anything, then I'd go for JSON
-
Yaml is for me a broken concept.
I don't know how why the idea to use whitespace / non printable characters based blocks seems to be popular... Python did it... And every one falls now or then on it's nose thanks to it.
One reason that seems to be even more popular is to safe keystrokes I guess - seems to be popular, too.
For me it boils down to one important no go: Omitting information and hence correctness out of lazyness.
Whenever I can I avoid yaml as much as possible.... It's just stupid that you'll have to at least let an parser run over it to be sure you didn't fuck up...
Especially in larger configuration files it's just a pain in the arse -
When it comes to configuration wich you do not want to write in the language your are writing the software in, YAML is king.
I like:
- Enforced proper indenting, making the data structure parsable at a glance.
- Still relatively lightweight when stripping the features you don't need.
I dislike:
- References. They are basically an invitation for expansion bombs.
- Type annotations. I like my configs to only have the most basic types (bool, number, UTF-8 text). Which are checked/validated and translated to more specific types by specialized parsers after the YAML parser did its work.
- That i have to google for the right markup for text types every time.
JSON is good for RPCs and other machine-to-machine communication. It is even more lightweight than YAML and still readable enough for a developer in debug output.
Just avoid XML if you can. It is the definition of bloat and comes with some nasty designed-into-the-language exploit surface wich you have to carefully mitigate. -
Without a doubt -- json.
I know yaml is designed to be lightweight and readable, yada yada.
Lightweight it is! Can't argue with that. But readable...? Not quite. Sometimes indentations visually appear in the same level as parent item [lists]. It's hard to know where you are in a list of objects [in json terms], a critical prod data fuckup is no more but a single space away [unfortunately it's a true story].
With json you always know where you are - just find the nearest structure boundary ([ or {). And it's hell of a more difficult to make a structural mistake and have a valid json at the same time -- you'll have your boundaries fucked up and you will be forced to review the whole thing and fix it. -
@netikras
No matter whether you go for YAML or JSON - you are _always_ just one typo away from messing up the data in some way. Sometimes it still parses, sometimes it doesn't.
JSON might be slightly more brittle when it comes to syntax (wich is a good thing for catching typos). But i experienced YAML to always be far more readable than JSON, wich also leads to less typos in the first place...
For actual typo-detection in human-provided configuration, you need to use a more redundant language. Numbers could for example be written as text ("nine" instead of "9")...
For obvious reasons, such redundant configuration language is enforced nowhere in IT (although numbers are written as text on cheques in my country and true/false are almost never configured as "1"/"0" in example configuration). -
hitko31485yDownsides of YAML:
https://arp242.net/yaml-config.html...
https://github.com/cblp/yaml-sucks
https://noyaml.com/
Downsides of JSON:
it adds a lot of markup and escaped values
harder to read / write
no comments
That being said I don't necessarily say you should use JSON as YAML is clearly a better choice when readability is a priority, but there's a lot to consider if you choose YAML, especially in untrusted environment or when communicating parties don't use the exact same implementation. -
Whichever one has built-in support so i don't have to write more fucking code or import more fucking modules.
-
bahua129045yYAML is inherently harder to read because you literally cannot see the characters that will break it.
-
neither. Put settings on a regular . txt file, read them and parse the required settings etc.
Also available options: environmental variables everywhere. -
Flygger19815y.INI — at least as readable and lightweight as the rest of them and far harder to manually screw up ;)
-
YAML vs Json
question