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?

top 50 comments

sorted by: hot top controversial new old
[–] 84 points 2 years ago (10 children)

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.

  • source
  • hideshow 11 child comments
  • [–] 25 points 2 years ago (7 children)

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

  • source
  • parent
  • hideshow 10 child comments
  • [–] 63 points 2 years ago (8 children)

    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.

  • source
  • parent
  • hideshow 9 child comments
  • load more comments (7 replies)
  • [–] 29 points 2 years ago (3 children)

    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

  • source
  • parent
  • hideshow 5 child comments
  • [–] 17 points 2 years ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 8 points 2 years ago* (4 children)

    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.

  • source
  • parent
  • hideshow 5 child comments
  • load more comments (3 replies)
  • load more comments (1 reply)
  • load more comments (4 replies)
  • load more comments (9 replies)
    [+] 63 points 2 years ago* (last edited 1 year ago) (4 children)
  • [–] 11 points 2 years 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.

  • source
  • parent
  • hideshow 4 child comments
  • load more comments (2 replies)
  • load more comments (1 reply)
    [–] 43 points 2 years ago* (8 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.

  • source
  • hideshow 8 child comments
  • load more comments (8 replies)
    [–] 40 points 2 years ago (3 children)
  • load more comments (2 replies)
    [–] 35 points 2 years ago (2 children)

    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".

  • source
  • hideshow 4 child comments
  • [–] 12 points 2 years ago* (last edited 2 years ago) (7 children)

    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.

  • source
  • parent
  • hideshow 7 child comments
  • load more comments (7 replies)
  • [–] 31 points 2 years ago

    Following along with the style of your own post: YAML doesn't suck, because I feel so.

    Thanks for asking.

  • source
  • [–] 26 points 2 years ago* (last edited 2 years ago)

    One pattern I've noticed is people seeking a language that's better than {JSON,XML,INI,etc} at wrangling their slightly complex configuration files, noticing the additional features and type support offered by YAML, and assuming it will be a good solution.

    Then, as their configs grow ever larger and more complex, they discover that expressing them in YAML requires large sections of deep nesting, long item sequences, and line wrapping. The syntax style that they saw working well in other places (e.g. certain programming languages) breaks down quickly at that level of complexity, making it difficult for humans to correctly write and follow, and leading to frequent errors.

    YAML doesn't suck for small stuff, IMHO. (But it is more complex than necessary for small stuff.)

    For things likely to grow to medium-large size or complexity, I would recommend either breaking up the data into separate files, or looking for a different config/serialization language.

  • source
  • [–] 26 points 2 years ago (2 children)

    I don’t like YAML because it’s overly complicated. The specification is like 80 pages long. How the hell did they think that was a good idea?

    JSON on the other hand is super simple. It doesn’t do more than it needs to.

    Just compare this: https://yaml.org/spec/1.2.2/

    With this: https://www.json.org/json-en.html

    The entire JSON specification is shorter than just the table of contents of the YAML specification!

    Another thing I like about JSON is that you can format it however you want with the whitespace. Want everything on one line? Just write everything on one line!

    If data can be represented as a JSON, then there’s generally only one way to represent it in JSON (apart from whitespace). In YAML the same data can be represented in 1000s of different ways. You pick one.

  • source
  • hideshow 4 child comments
  • [–] 13 points 2 years ago

    This is the major reason for me. I really liked yaml, because it is way more readable to me than JSON. But then I kept finding new and more confusing yaml features and have realized how over-engineered it is.

    Yaml would be great language if it had its features prunned heavy.

  • source
  • parent
  • [–] 20 points 2 years 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.

  • source
  • hideshow 2 child comments
  • load more comments (2 replies)
    [–] 19 points 2 years ago* (last edited 2 years 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.

  • source
  • [–] 19 points 2 years ago

    YAML works great for small config files, or situations where your configuration is fully declarative. Go look at the Kubernetes API with its resources.

    People think YAML sucks because everyone loves creating spaghetti config/templates with it.

    One reason it tends to become an absolute unholy mess is because people work around the declarative nature of those APIs by shoving imperative code into it. Think complicated Helm charts with little snippets of logic and code all over the place. It just isn't really made for doing that.

    It also forces your brain to switch back and forth between the two different paradigms. It doesn't just become hard to read, it becomes hard to reason about.

  • source
  • [–] 18 points 2 years ago

    I don't like a thing, fellas. With that being all I've told you, please explain why I don't like that thing.

  • source
  • [–] 18 points 2 years ago (1 child)

    I think TOML should replace YAML for config files, it is much clearer, easier to parse for a human.

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 16 points 2 years ago (1 child)

    It sucks the same way Python sucks. Some people just really don't like indentation-based syntax. I'm one of them, so I dislike both formats. However, if you groove on that sort of thing, I don't think YAML is any worse than any other markup.

    Oddly, I get along with Haskell, which also used indentation for scoping/delimiting; I can't explain that, except that, somehow, indentation-based syntax seems to fit better with functional languages. But I have no clear argument about why; it's just an oddity in my aesthetics.

  • source
  • hideshow 2 child comments
  • [+] 16 points 2 years ago* (last edited 1 year ago) (1 child)
    load more comments (1 reply)
    [–] 13 points 2 years ago (2 children)

    I like yml. Clean to read, easy to use, supports comments.

  • source
  • hideshow 2 child comments
  • load more comments (2 replies)
    [–] 13 points 2 years ago

    But.. Yaml ain't markup language..

  • source
  • [–] 13 points 2 years ago (1 child)

    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.

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 12 points 2 years ago (1 child)

    it does what it needs to do: i don't think it's necessarily bad.

    it's for data not programming and it handles complex structures cleaner than json

  • source
  • hideshow 2 child comments
  • [–] 12 points 2 years ago

    YAML had comments and trailing commas, therefore it's objectively better than JSON. If you want a compromise solution that mostly looks like JSON, try JSON5.

  • source
  • [+] 11 points 2 years ago* (last edited 3 months ago)
    [–] 11 points 2 years ago (1 child)

    I don't hate YAML, but it has the same issues languages like PHP and JS introduce...there are unexpected corner cases that only exist because the designer wanted the language to be "friendly"

    https://www.bram.us/2022/01/11/yaml-the-norway-problem/

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 8 points 2 years ago

    We all know it sucks. I have no idea why people use it instead of anything else. My workday is jammed with fucking ansible which, while also being so ghetto that we were easily doing more with less in 2002, uses So.much.fucking.yaml . Just when you think ansible couldn't get more clunky and useless and slow, it also is configured in yaml.

  • source
  • load more comments
    view more: next ›