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?

82 points

Any language in which whitespace has syntactic value is intrinsically flawed.

Can’t speak to your specific issues, but that’s why yaml will always suck.

permalink
report
reply
25 points

As a serialization format, agree 100%, but would Python really be better if it switched to braces?

permalink
report
parent
reply
61 points

Yes, I think so. The downside with Python comes when refactoring the code. There’s always this double checking if the code is correctly indented after the refactor. Sometimes small mistakes creep in.

It’s really hard to tell when Python code is incorrectly indented. It’s often still valid Python code, but you can’t tell if it’s wrong unless you know the intention of the code.

In order languages it’s always obvious when code is incorrectly indented. There’s no ambiguity.

permalink
report
parent
reply
13 points

I think this is just familiarity. I never have issues with indentation, but when refactoring js I’m always like hey who’s fucking brace is this

permalink
report
parent
reply
6 points

It’s only hard to tell indentation in Python when the code block gets longer than about a screen, which is usually a sign the code should be refactored into smaller methods.

permalink
report
parent
reply
1 point
*

Can address it by writing code that doesn’t depend much on indentation, which also makes code more linear and easier to follow.

permalink
report
parent
reply
28 points

Yes it would - look at optional braces for short if expressions in C family languages and why it’s so discouraged in large projects. Terminating characters are absolutely worth the cost of an extra LoC

permalink
report
parent
reply
15 points

I started in C before moving on to C++, Java, Ruby and Python.

I’ve had more bugs from missing braces than from misaligned whitespace because the latter is far more obvious when looking at a block of code.

permalink
report
parent
reply
7 points
*

False dichotomy. Optional braces are bad practice because they mislead the programmer that is adding an additional clause to the block.

This misleading behavior wouldn’t happen in Python, as it would either be invalid syntax, or it would be part of the block.

Indentation problems are pretty obvious to the reader. Even more than missing or unbalanced braces.

permalink
report
parent
reply
4 points

I’m fine with python, because it’s consistent. In C I get nervous every time I see it.

obligatory goto fail;

permalink
report
parent
reply
16 points
*

would Python really be better if it switched to braces?

Yes. A thousand times, yes.

permalink
report
parent
reply
5 points

To be pendantic, it’s level of indentation in Python that has semantic meaning, not whitespace.

permalink
report
parent
reply
13 points

The end of line also has semantic meaning. Both indentation and eol are whitespace.

permalink
report
parent
reply
2 points

If nothing else it enforces readable code which I think is a good thing.

permalink
report
parent
reply
7 points
*

Haskell supports both semantic whitespace and explicit delimiters, and somehow almost everybody that uses the language disagrees with you.

But anyway, for all the problems of YAML, this one isn’t even relevant enough to point out. Even if you agree it’s a problem. (And I agree that the YAML semantic whitespace is horrible.) If YAML was a much better language, it would be worth arguing whether semantic whitespace breaks it or not.

permalink
report
parent
reply
0 points

Yeah but Haskell is mostly used by mathematicians…

permalink
report
parent
reply
6 points
*

YAML sucks because, among other things, indenting it is not obvious.

In contrast, the only mistake of Python when it comes to whitespaces was allowing hard tabs, which makes it too easy to mix them if your editor is not configured.

Improper indentation stands out more than missing or unbalanced braces and it’s really not an issue to delimit code blocks.

permalink
report
parent
reply
8 points
Deleted by creator
permalink
report
parent
reply
1 point

In any modern editor it is configurable with spaces too

permalink
report
parent
reply
2 points

Not any language. I code professionally in F# which has semantic whitespace and it has literally never been an issue for me or my team. In contrast to Python, it’s a compiled language and the compiler is quite strict, so that probably helps.

permalink
report
parent
reply
1 point

It’s the only time that tabs Vs spaces really riles me up. So annoying when everyone has different tab lengths

permalink
report
parent
reply
-1 points

I now use Scala 3, and very happy with syntactic whitespace (combined with an intelligent compiler)

permalink
report
parent
reply
62 points
*

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

permalink
report
reply
46 points
*

Can you stop hating on haters? Thanks 😄

permalink
report
parent
reply
26 points

stop hating on rust devs

permalink
report
parent
reply
11 points

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.

permalink
report
parent
reply
8 points

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.

permalink
report
parent
reply
4 points

What’s wrong with using YAML for CI? I mean, I use it for Gitlab CI, the underlying script it runs is just Bash.

permalink
report
parent
reply
1 point

I dream of a life where I use YAML but all my configs are stuck in XML. People can complain but there’s always worse options.

permalink
report
parent
reply
2 points

One nice thing about XML is that there’s an official way to link to the schema from within the document. If you do that you can easily automatically validate it, and even better you get fantastic IDE support via Red Hat’s LSP server. Live validation, hover for keys, etc.

It’s a really nice experience and JSON schema can’t really match it.

That said, XML just has the wrong data model for 99% of use cases.

permalink
report
parent
reply
6 points

No seeds no stems no stress my guy. The Internet is a great place for complaining. Readers can downvote and move on, everyone gets what they want.

permalink
report
parent
reply
42 points
*

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.

permalink
report
reply
7 points

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.

permalink
report
parent
reply

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?

permalink
report
parent
reply
4 points

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?

permalink
report
parent
reply
6 points

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

permalink
report
parent
reply

Pleased to have touched your life with levity, stranger.

permalink
report
parent
reply
1 point

I write my specs in C++

permalink
report
parent
reply
41 points
17 points

That is amazing.

I don’t know what I just read.

If my website ever gets married, I’m going to invite this website to stand next to it as a bridesmaid - because it makes my website look pretty by comparison.

permalink
report
parent
reply
7 points

Sadly, unreadable on mobile. Text doesn’t word wrap, dragging to pan it is annoying and makes the keyboard show up.

permalink
report
parent
reply
2 points

Most of the stuff here can be avoided by using quotes for strings…

permalink
report
parent
reply
34 points

Because people over use it. YAML is pretty good for short config files that need to be human readable but it falls apart with complex multi line strings and escaping.

I think there are much better clearly delimited for machine reading purposes formats out there that you should prefer if you’re writing a really heavy config file and, tbh, I think for everything else .ini is probably “good enough”.

permalink
report
reply
28 points

At least use TOML if you like ini, there is no ini spec but TOML can look quite similar.

permalink
report
parent
reply
10 points

Strong agree. It’s also the absolute best at expressing really long documents of configuration/data.

permalink
report
parent
reply
13 points
*

I agree - YAML is not suitable for complex cases that people use it in, like Terraform and Home Assistant. My pet peeve is a YAML config in a situation that really calls for more abstraction, like functions and variables. I’d like to see more use of the class of configuration languages that support that stuff, like Dhall, Cue, and Nickel.

There is another gotcha which is that YAML has more room for ambiguity than, say, JSON. YAML has a lot of ways to say true and false, and it’s implicit quoting is a bit complex. So some values that you expect to be strings might be interpreted as something els.

permalink
report
parent
reply
5 points
*

For those highly complex situations is Lua still viewed as the ideal solution? Lua is sort of legendary for game configuration and seems to strike a good expressiveness/accessibility balance for modders and the casually technical.

permalink
report
parent
reply
1 point

I think it depends. Lua is great for scripting - like when X happens do Y. I agree that makes sense for a case like Home Assistant. Sometimes you really want the result to be a data structure, not an interactive program, in which case I think more sophisticated configuration (as opposed to scripting) languages might be better.

permalink
report
parent
reply
3 points

What YAML does Terraform use? HCL is similar but different enough to YAML.

permalink
report
parent
reply
4 points

Oh, thanks for calling that out. I think I may have mixed up some of the frustrations I experienced at an old job.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

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



Community stats

  • 2.3K

    Monthly active users

  • 1.8K

    Posts

  • 29K

    Comments