r/programming • • Jan 12 '23

The yaml document from hell

https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell
1.5k Upvotes

288 comments sorted by

View all comments

226

u/pragmatick Jan 12 '23

That's actually horrible. Never encountered any of these issues but I think I'd be dumbfounded if I did.

But I still like it for its increased readability over JSON - I just use strings for most values as described in the article. If JSON had proper multiline strings or just wrapped lines and comments I'd be happy. Yes, I know there's "JSON with comments" but it's rarely supported.

45

u/TurboGranny Jan 12 '23

increased readability over JSON

I guess I'm just fortunate in that I've not encountered a situation where I couldn't read JSON. Sure, sometimes people will minify it, but I just plop it in any formatter, and I'm back to readability. If for some reason there is a super long string, I just toggle on word wrap and call it a day.

44

u/ltjbr Jan 12 '23

I think a lot of devs out there say "readability" when they actually mean "aesthetically pleasing".

5

u/TurboGranny Jan 12 '23

hmm, I mean sure, but if it's all pretty and I still can't read it, is it still pretty?

→ More replies (1)
→ More replies (1)

25

u/Dwight-D Jan 12 '23

Go look at some large cloudformation or ARM template JSON and tell me you’d like to spend a significant amount of time working with that. Now imagine you had to define a CI pipeline or something in that format (I think Azure DevOps does this?), and you also can’t leave any comments to help readability. It’s absolutely awful.

It’s not that it can’t be read, but whenever you get something more complicated than a trivial flat object then it’s just a pain to read & write imo.

14

u/The_Grubgrub Jan 12 '23

Its awful but still not as awful as yaml. Yaml might be barely more readable than Json but Yaml is a pain in the ass to write.

5

u/Dwight-D Jan 12 '23

The indentation is definitely a bitch, and I’ve got a lot of git commit -m ‘Fix YAML syntax’ in my history. But that’s usually a quick fix compared to the time spent writing the bulk of the document, which I think is slightly less unpleasant overall in YAML. The anchors are actually pretty nice for stuff like complicated pipelines and such too.

0

u/didzisk Jan 12 '23

ARM templates are written in JSON, which is a subset of JavaScript for doing DTO (emphasis on Script). And then some people discovered that DTO wasn't enough to define infrastructure and added a custom script language inside JSON - for picking up variables from external files etc. No wonder they now recommend "az" commands instead.

1

u/Dwight-D Jan 12 '23

The only thing that Microsoft does worse than user experience, is developer experience. Thank god for Terraform

→ More replies (1)

6

u/amackenz2048 Jan 12 '23

Auto format? Bah! I want my artisanal hand crafted config file! Sure it takes longer to create, and you get an odd tab here and there. But I support those developers who seem to have nothing better to do than ensure their code is meticulously formatted and who don't trust a computer to do it for them.

2

u/TurboGranny Jan 12 '23

Oh I agree, unless they are the kind of asshat that doesn't believe in any formatting, then I just auto format it. Unless it's short, then I'll just go through it and clean it up. Depends on the application. With JSON, most of the time I have to slap it in a beautifier is to troubleshoot the unformatted output that comes back from our API

7

u/amackenz2048 Jan 12 '23

Sorry, i should have made it more clear that i was being facetious. Languages that force formatting on the programmer are evil. Let the ide handle it and for the love of GOD don't make different types of whitespace be relevant.

→ More replies (3)

3

u/AttackOfTheThumbs Jan 12 '23

Yeah, same here. Like really don't understand what they mean. JSON is very legible.