3 ms·
>However, I cannot bring myself to like meaningful whitespace. YAML has given me enough headaches in life in a scant year, that I am pretty firmly on the opposi
by crdoconnor 9y ago
>However, I cannot bring myself to like meaningful whitespace. YAML has given me enough headaches in life in a scant year, that I am pretty firmly on the opposite side of that fence now.
The only time YAML gives me a headache with respect to whitespace is when I'm using block literals which have trailing whitespace. I don't think any other serialization format really deals with that problem well though - either you have a long, nicely readable block of text that looks ambiguous with trailing whitespace or you have a nasty escaped "long string with \n\n \n\'s" everywhere.
Block literals: |
are a killer feature, too.
They are so damn useful when you have strings
spanning multiple lines.
Meaningful whitespace means that syntactic clutter can be removed. That makes the markup much more readable because there's less distracting syntactic noise. YAML diffs are very readable, for instance, but JSON diffs (as well as diffs for every other kind of serialization format without meaningful whitespace), are very much not.
- taeric 9y agoI can't remember the parts that pained me most. Some were in somewhat odd sounding "lists of single items" versus "list of single dict items" and such. In particular, the vast difference between: baz: bat: - foo: bar and baz: bat: - foo: bar is not at all obvious at a glance to me. If I convinced everyone to move to 4 or 8 character indents, it would stick out a little more, but I don't see myself winning that fight. Worst of all, this mistake happened when I was moving some template from one place to another in a different file. Should be easy. Copy, paste, fix whitespace. The problem is that "fix whitespace" has to know about the copy/paste. You can't just reformat after the fact. Yes, tooling could "paste with indentation for current cursor" but you literally cannot "paste, then fix whitespace." It is like the worst of outlooks "paste with formatting".
- crdoconnor 9y agoI actually wrote a YAML parser that closed this loophole by raising an exception on YAML files that have inconsistent indents. Somebody reported exactly that as an issue on my issue tracker: https://github.com/crdoconnor/strictyaml/issues/23 https://github.com/crdoconnor/strictyaml/issues/23 I'm aware that there are a bunch of annoyances like that, but I'm still convinced the core is good and making a new standard which is stricter solves most of these issues. FWIW, I haven't run into this problem personally but it's pretty obvious that it is a problem.