5 ms·
What is the obsession with removing braces? I will never find the lack of clear demarcations (relying on indent) easier than braces.
by diob 5y ago
What is the obsession with removing braces? I will never find the lack of clear demarcations (relying on indent) easier than braces.
- rhn_mk1 5y agoIsn't an indent a clear demarcation?
- zmmmmm 5y agoOnly if you forbid tabs ...
- a9h74j 5y agoIf it must be created by non-programmers too delicate to match braces, how about BEGIN .. END and an autoformatter. Or, NODE <name> .. END .
- aimor 5y agoLiterally, yes. But I find it incredibly annoying to estimate indentation when lines are wrapped in an editor (or webpage). Or, to a lesser extent but still throws me off, when multiple blocks end at the same line. Or when pasting blocks into another block, and having to double check to make sure the indentation was carried over correctly. I like editors that visually show indentation characters.
- dylan604 5y agotabs or spaces for that indent? it makes a difference on how it is parsed, so it's more than a devs preference
- kevincox 5y agoIt really doesn't matter. Just force the leading indent to be exactly the same bytes. If indent moves between two values where one isn't a prefix of the other raise an error.
- dylan604 5y agois one \t the same as \s{4,} in bytes? that doesn't make any sense
- kevincox 5y agoNo it isn't. That is the point. If you have one line indented with 4 spaces and one line indented with a tab there is no correct answer what the difference of indent is. The only good option is to raise an error.
- dylan604 5y agoright, or encapsulate in some sort of braces ;-)
- kevincox 5y agoSure, that is another option. But your code still looks confusing. Personally I mostly use indent to read code, so requiring that the indent matches the semantic nesting makes it much easier for me to understand.
- dylan604 5y agoLooks confusing to who? Another coder? Then they have issues. I get the original was talking about client facing config files. I'd rather see INI style config files personally. If you're writing ugly code, braces or spaces won't save you. Just don't write ugly code.* Write it like the next person to view your code is an axe murder that knows where you live, so don't make them mad. You can minify later. *I'm ignoring Perl, as it's always ugly
- goodpoint 5y agoNot at all. If it was code, an indentation error would often not compile or show errors or fail tests. Configuration in YAML is much worse: most of the time an indentation error goes undetected until an application starts misbehaving. Significant whitespace is perfectly ok for code but a huge footgun for YAML
- andybak 5y agoVisual 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
- cbarrick 5y agoAn underrated property of braces in this case is that a truncated document is no longer valid (assuming your document only has one top-level item). Truncate YAML and in most cases you still have valid YAML.