this post was submitted on 06 Sep 2024
62 points (73.8% liked)

Programming

17351 readers
355 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
62
Why YAML sucks? (programming.dev)
submitted 2 months ago* (last edited 2 months ago) by heikkiket@programming.dev to c/programming@programming.dev
 

I feel that Yaml sucks. I understand the need for such markup language but I think it sucks. Somehow it's clunky to use. Can you explain why?

(page 2) 50 comments
sorted by: hot top controversial new old
[–] mindbleach@sh.itjust.works 7 points 2 months ago

"Why does YAML suck?" is a question. "Why YAML sucks" is an explanation.

[–] GTG3000@programming.dev 7 points 2 months ago

It's inconsistent and annoying. Expressive, yes. Gets it's job done, yes. Absolute nightmare of a spec, YES.

The fact that JSON is a subset of YAML should tell you everything about how bloated the spec is. And of course there's the "no" funny things.

Personally, my favourite way to write configs was using lua (because it was already part of the project so why not), but JSON does fine.

[–] thingsiplay@beehaw.org 6 points 2 months ago

I don't like it either, but I'm not entirely sure why. Maybe the biggest flaw to me is it uses Python style indentation for structuring as part of data logic. It doesn't feel like a configuration language to me and it does not feel simple too. It's also unlike most programming language structures (maybe besides Python), so it looks weird to read and write. Other than that, I don't know exactly why I don't like this format much. Admittedly, I did not do much in YAML, so because lack of experience take my opinion with a thick grain of salt.

We have JSON and TOML. I quiet like TOML. We have "better" alternatives, that are probably easier to parse. And therefore there is not much need for YAML. Maybe if YAML was the default config format for Python it would get off the ground and be accepted more often.

[–] ulkesh@beehaw.org 5 points 2 months ago

White space/indentation as a construct of the syntax.

It’s why I have a hard time with python.

People have their likes and dislikes. Nothing wrong with that.

[–] NostraDavid@programming.dev 4 points 2 months ago* (last edited 2 months ago) (4 children)

YAML is fine if you use a subset (don't use the advanced features - not like you know those anyway) and use explicit strings (always add " to strings), otherwise things may be cast when you did not intend values to be cast.

Example:

country: NO (Norway) will be cast to country: False, because it'll cast no (regardless from casing) to false, and yes to true.

country: "NO" should not be cast.

load more comments (4 replies)
[–] RubberElectrons@lemmy.world 4 points 2 months ago
[–] lemming741@lemmy.world 4 points 2 months ago

It's a rube goldberg footgun

[–] cosmicbytes@programming.dev 3 points 2 months ago (1 children)

I wish s-expression was a popular alternative. It's readable without the yaml issues.

load more comments (1 replies)
[–] Damage@feddit.it 3 points 2 months ago

I think much of the issue with YAML is that it's often paired with bad editors. You need a way to manage the whitespace, collapse sections, etc. Notepad doesn't cut it.

load more comments
view more: ‹ prev next ›