this post was submitted on 06 Sep 2024
61 points (74.0% liked)

Programming

17666 readers
58 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 [email protected]



founded 2 years ago
MODERATORS
61
Why YAML sucks? (programming.dev)
submitted 3 months ago* (last edited 3 months ago) by [email protected] to c/[email protected]
 

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
[–] [email protected] 11 points 3 months ago (1 children)

I hated yaml with every fiber of my being when first had to use it, but I really wanted to use HomeAssistant and see what I could do with it. I hated it a bit less when I started using docker compose. I started loving it when I started using it as a way to explain json to non-programming IT types, trying to explain it without braces and brackets seems to get across easier. I guess its more human readable, but as a result formatting has to be spot on (those indents and spaces replace the need for brackets and braces).

One useful trick if you truly hate it but need it, write it in json, then just use a converter to change that into yaml.

load more comments (1 replies)
[–] [email protected] 4 points 3 months ago* (last edited 3 months ago) (1 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.

[–] [email protected] 2 points 3 months ago* (last edited 3 months ago) (3 children)

People are working on making S-Expressions a standard: https://datatracker.ietf.org/doc/draft-rivest-sexp/

Note: This is just a draft, but improvements have been happening since 2023.

I probably won't like the parentheses, but I think I'll take it over yaml/json/whateverelse.

load more comments (3 replies)
[–] [email protected] 20 points 3 months ago (2 children)

To paraphrase: There are two kinds of markup languages. Those that people complain about and those that nobody uses.

There is no silver bullet that will work perfectly for all use cases and we also don't want to use 100 different tools. So people use things that aren't perfect. But they're good enough. I don't think YAML is perfect and I still use it, because people know it and there are tons of tools already available.

load more comments (2 replies)
[–] [email protected] 7 points 3 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.

[–] [email protected] 18 points 3 months ago* (last edited 3 months ago)

Tons of people making Python comparisons regarding indentation here. I disagree. If you make an indentation error in Python, you will usually notice it right away. On the one hand because the logic is off or you're referencing stuff that's not in scope, on the other because if you are a sane person, you use a formatter and a linter when writing code.

The places you can make these error are also very limited. At most at the very beginning and very end of a block. I can remember a single indentation error I only caught during debugging and that's it. 99% of the time your linter will catch them.

YAML is much worse in that regard, because you are not programming, you are structuring data. There is a high chance nothing will immediately go wrong. Items have default values, high-level languages might hide mistakes, badly trained programmers might be quick to cast stuff and don't question it, and most of the time tools can't help you either, because they cannot know you meant to create a different structure.

That said, while I much prefer TOML for being significantly simpler, I can't say YAML doesn't get the job done. It's also very readable as long as you don't go crazy with nesting. What's annoying about it is the amount of very subtle mistakes it allows you to make. I get super anxious when writing YAML.

[–] [email protected] 60 points 3 months ago* (last edited 3 months ago) (4 children)

Can people stop hating on shit?

FOR FUCKS SAKE, negative reinforcement dopamine has RUINED THE FUCKING NET.

EVERYWHERE I GO there's someone bitching about something, hate circlejerks are unbelievably popular, people just love to hate on stuff.

You're ruining your thought patterns with all these social media negativity bullshit.

Fucking TOML users hate on fucking YAML fucking C++ users hate Rust fucking Rust users hate literally everything under the sun and are insufferable to work with

EVERYONE, fucking CHILL

[–] [email protected] 26 points 3 months ago

stop hating on rust devs

[–] [email protected] 11 points 3 months ago (3 children)

Yeah TBH I like yaml. Sure its not the best ever, but its not the worst it could possibly be.

For config its not terrible. For ansible playbooks its again... not terrible.

Why is everyone always hating on something which is just kinda mid.

[–] [email protected] 8 points 3 months ago (3 children)

Config is fine, but Yamls biggest problem is people use it to describe programs. For example: playbooks. For example: CI steps.

If YAML wasn't abused in this way it would have a lot less hate.

load more comments (3 replies)
load more comments (2 replies)
[–] [email protected] 46 points 3 months ago* (last edited 3 months ago)

Can you stop hating on haters? Thanks 😄

load more comments (1 replies)
[–] [email protected] 16 points 3 months ago (1 children)

I didn't use yaml much while it was gaining popularity, and therefore didn't pay much attention. But this article really made me pay attention and now I distrust anything that uses yaml in any capacity.

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

[–] [email protected] 5 points 3 months ago

Great link.

[–] [email protected] 42 points 3 months ago* (last edited 3 months ago) (3 children)

Programmers hate everything. You could design a spec which serenades you with angel song and feeds you chocolate dipped grapes and someone would be like: This is awful, my usecase is being a dog.

[–] [email protected] 1 points 3 months ago

I write my specs in C++

[–] [email protected] 7 points 3 months ago (1 children)

Sure there aren't many things that are universally loved. I mean I can't really think of anything that doesn't have some flaw.

But that doesn't mean everything is equal! What would you rather program with, Visual Basic or Go? PHP or Typescript? If you polled people there are obvious winners.

[–] [email protected] -2 points 3 months ago (1 children)

Hey would you rather build from wood or steel?

What glue is better: 2 part epoxy or PVA?

Do you prefer soap or bleach as cleaning agent?

[–] [email protected] 4 points 3 months ago (2 children)

Would you rather build from wood or tissue paper?

What glue is better: 2 part epoxy or pritt stick?

Do you prefer soap or ash as a cleaning agent?

load more comments (2 replies)
[–] [email protected] 6 points 3 months ago (1 children)

This comment is underrated, even if it rises to the top of all comments.

[–] [email protected] 4 points 3 months ago

Pleased to have touched your life with levity, stranger.

[–] [email protected] 0 points 3 months ago

cradles yaml in her hands and coos don't you talk to my baby like that! she has potential !

load more comments
view more: ‹ prev next ›