5 ms·
Visual clutter, familiarity to non-coders. Curly braces are almost never used outside of programming and are ugly to boot. My benchmark for yaml/JSON alternati
by andybak 5y ago
Visual clutter, familiarity to non-coders. Curly braces are almost never used outside of programming and are ugly to boot.
My benchmark for yaml/JSON alternatives is "how would I feel explaining it to a busy, sceptical client?"
If the intended audience is purely developers, then sure. JSON (with the addition of comments and trailing commas) is just fine.
White space has the additional advantage of agreeing with itself. Other demarcations can have issues where the indentation and the structure contradict each other.
- diob 5y agoThat's just display though, if you have to show it to a skeptical client, why not run it through a browser that shows it without braces? It's the same as showing a webpage instead of the html.
- andybak 5y agoI was specifically thinking about asking clients to edit or write these files. Isn't that a fairly common use case for config languages?
- diob 5y agoThat's a good point someone brought up in a different comment. I haven't really dealt with those scenarios, so honestly I'll accept that as a reason. I wish it could be displayed with braces though, I wonder if someone already has built that as an extension for editing / viewing yaml files.
- colejohnson66 5y agoYAML is a superset of JSON. In other words: any syntactically valid JSON file is a valid YAML file. If you want braces like JSOM, but not quoted strings, YAML supports it.
- bmn__ 5y ago> YAML is a superset of JSON. That's false. http://p3rl.org/JSON::XS#JSON-and-YAML http://p3rl.org/JSON::XS#JSON-and-YAML
- initplus 5y agoIf programmers find getting YAML indentation correct difficult how are non-programmers going to fair?
- deadbunny 5y agoIf the HomeAssistant subreddit is anything to go by its their biggest complaint (HA configuration is in YAML). With that said if they weren't complaining about white space they'd be complainit about missing semicolons, missing/extra commas, missig equals signs, missing closing )]} or whatever.
- andybak 5y agoAre you arguing "braces are easier to get right than indentation" or is this a point specific to YAML's rules? Because I'm not defending the latter but I find it hard to understand I would need to argue against the former.
- CJefferson 5y agoYou could run a formatter which adds braces if you like?
- forrestthewoods 5y agoSignificant whitespace is evil. It's just begging for copy/paste bugs.
- andybak 5y agoFunny that's never been an issue for me after 2 decades of writing Python.
- zippergz 5y agoI haven't found "this needs to be indented exactly the right amount or it won't work" to be much easier for non-programmers than "this needs to be enclosed in braces or it won't work." Most people have at least experienced parentheses in math (albeit maybe decades ago), so it's not an entirely foreign concept. Either one requires a bit of learning, but I think most people are capable of it, so any improvement in non-coder familiarity seems minor at best, vs. the very real costs.
- szastamasta 5y agoAgain the dreaded Cobol argument. We had to struggle with a lot of this in the past: Cobol, SQL, YAML, BDD. All this would be much easier without this nonsensical idea that nontechnical people will read code. They won’t. Making code a bit more like prose doesn’t make it readable for nontechnical people. Yet we again and again make our life harder - ugly syntax rules, no code completion, no auto-formatters. Please stop making code easy for non-coders. They don’t want to read it. They never did. They just want this damn box to work.
- gmadsen 5y agoas a counter argument. I work in robotics, where many operators will look at and change settings in a yaml file during testing. They do not have software skills outside of this.
- eitland 5y agoMy educated guess then is you could have gotten them to change "settings" in C, Java or basically anything. Just put the file in the root folder, and keep it as simple as possible and you should be fine? I mean, if they manage to write yaml correctly and consistently C is no match?
- gmadsen 5y agomaybe? the dynamic loading of the configs kind of restricts it to a markup language.
- sockpuppet_12 5y agoThe reason the situation is the way it is now is precisely because the code being made easy for non-coders increased the popularity and reach of the products. Probably because non-coders also found it easy to pick up and start working with it.
- andybak 5y agoWrong use case. I'm talking about asking them to write it edit these files.
- jstx1 5y agoThis makes zero sense to me. Why do config files out of all things have to be accessible to non-coders?
- andybak 5y agoBecause we are asking them to write these things in many cases.
- jstx1 5y agoI'm not buying that you genuinely have a target audience of "I trust this person with config files but their eyes are too gentle to see a curly brace".
- andybak 5y agoWell. I've genuinely had clients editing YAML so there's that. I can definitely think of a broad range of people where I'd be happy to recommend they use text files for config and data but I wouldn't be happy if those text files needed to follow the rules of JSON syntax. I mean - to some extent I would rather not edit JSON. It's not a terribly ergonomic experience. If I had to design a format for my own use, it would be indentation based and probably look a little bit like YAML, Markdown or similar.
- remram 5y agoBecause they're not code?
- diob 5y agoMy google ability didn't see anything, but are their any case studies that show it's more readable? I'm happy to accept that it is, but I can't help wondering if research has been done or it's mostly gut feeling / anecdotes / aesthetics.
- andybak 5y ago> that show it's more readable? I'm not clear exactly what the "it" here refers to but as I mentioned in other comments it's fairly self-evident that indentation is easier to visually parse than braces. A simple thought experiment - would you find it easier to skim read code where the indentation was consistent with the bracing or where it was inconsistent? Your brain registers the indentation first and you only resort to counting braces if there's a reason to doubt the former.
- diob 5y agoReality often times runs counter to our expectations though, which is why I wondered if no brace methods have been shown to enable simpler to understand usage / understanding.
- andybak 5y agoMy point was that the debate is between "indentation alone is sufficient" and "braces plus indentation is better than just indentation". Nobody advocates for "braces are better without indentation". This surely implies that (practically) everyone agrees indentation is carrying most of the weight of visual indication of structure. Of course "everyone" might be wrong - but that's a fairly tricky corner to defend.
- egberts1 5y ago> Nobody advocates for "braces are better without indentation". ^^^ THIS ^^^
- vegai_ 5y ago>My benchmark for yaml/JSON alternatives is "how would I feel explaining it to a busy, sceptical client?" My benchmark is this: can an autoformatter do its job every time without breaking something that's technically working right now but possibly formatted wrong? Every data format that cannot comply with this contains in it a huge waste of time. Even as a python programmer, I extend the same rule to programming languages.