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?

  • Windex007@lemmy.world
    link
    fedilink
    arrow-up
    86
    arrow-down
    16
    ·
    1 year ago

    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.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      10
      arrow-down
      4
      ·
      1 year ago

      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.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      9
      arrow-down
      3
      ·
      edit-2
      1 year ago

      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.

    • MajorHavoc@programming.dev
      link
      fedilink
      arrow-up
      17
      arrow-down
      2
      ·
      1 year ago

      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.

    • tibi@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

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

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    29
    arrow-down
    1
    ·
    1 year ago

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

  • gencha@lemm.ee
    link
    fedilink
    arrow-up
    26
    ·
    1 year ago

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

    Thanks for asking.

  • LyD@lemmy.ca
    link
    fedilink
    arrow-up
    16
    ·
    1 year 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.

  • state_electrician@discuss.tchncs.de
    link
    fedilink
    arrow-up
    17
    arrow-down
    1
    ·
    1 year ago

    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.

  • Reddfugee42@lemmy.world
    link
    fedilink
    English
    arrow-up
    16
    ·
    1 year 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.

  • UnfortunateShort@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    edit-2
    1 year 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.

  • lehenry@lemmy.world
    link
    fedilink
    arrow-up
    15
    arrow-down
    1
    ·
    1 year ago

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

    • NostraDavid@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Depends on the data structure. If you want to save a table of sorts, you’re getting a bunch of unreadable [[[]]] nonsense.

      For flat structures it’s great though.

  • ITGuyLevi@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    1 year ago

    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.

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Sorry, what’s confusing the fact that "Hi my name is {$this->name}" works and "Hi my name is {self::name}" is unintelligible gibberish! /s

  • demesisx@infosec.pub
    link
    fedilink
    English
    arrow-up
    9
    ·
    1 year ago

    I used to think json was the best until I found json lines or line delimited json. Thank me later. I use it all the time. You can append until you’re blue in the face. It’s great for log files. Each line is a valid json file.

  • 𝕽𝖚𝖆𝖎𝖉𝖍𝖗𝖎𝖌𝖍@midwest.social
    link
    fedilink
    arrow-up
    12
    arrow-down
    3
    ·
    1 year ago

    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.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      1 year ago

      You can’t say python’s whitespace usage is as bad as yaml’s. YAML mixes 2 and 4 spaces all the time. Python scripts don’t run if you write this kind of crap.

      And whitespaces is really just the tip of the iceberg of YAML problems…

        • Eager Eagle@lemmy.world
          link
          fedilink
          English
          arrow-up
          7
          ·
          edit-2
          1 year ago

          That’s part of the problem. Different number of whitespaces indicate different nesting levels and the YAML spec does not enforce them. These two horrible YAMLs are valid and are not equivalent:

          a:
           b:
               - c
               -  d
                - e
          f:
              "ghi"
          
          a:
           b:
               - c
               - d
               -  e
          f:
              "ghi"
          
          • zero_spelled_with_an_ecks@programming.dev
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            1 year ago

            So it’s easy to enforce locally but you don’t have to. And it’s easy to see indentation on modern IDEs and you can even make your indents rainbows and collapse structures to make it easier to see what’s going on, but I guess since some people want to write it in vi without ALE or a barebones text editor, it’s bad? Like there are legit reasons it’s bad, and other people have mentioned them throughout the thread, but this seems like a pretty easy thing to deal with. I work with ansible a bunch and YAML rarely is where my problem is.

            • atzanteol@sh.itjust.works
              link
              fedilink
              English
              arrow-up
              6
              ·
              1 year ago

              Jesus, just what I want to do with the devops team - spend a few weeks standardizing on an editor and configuring them to edit yaml.

              • zero_spelled_with_an_ecks@programming.dev
                link
                fedilink
                arrow-up
                1
                arrow-down
                1
                ·
                1 year ago

                A few weeks? How do you stay employed? How do you even feed yourself at that pace? Blocked on making a sandwich, I’ve got the wrong type of bread.

                It’s three lines in an editor config file to standardize the indents across any editor: https://editorconfig.org/

                In vscode, adding two extensions is all I need:, yamllint (if you don’t use linters, I don’t know how you do your job in any language) and rainbow indents. Atom had similar ones. I’m sure all IDEs are capable of these things. If you work at a place that forces you to use a specific editor and limits the way you can use it, that’s not YAML’s fault.

                At a certain point, it’s your deficiencies that make a language difficult, not the language’s. Don’t blame your hammer when you haven’t heated the iron.

      • atzanteol@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        2
        ·
        1 year ago

        YAML mixes 2 and 4 spaces all the time. Python scripts don’t run if you write this kind of crap.

        Sure it does. You only need to be consistent within a block. Python’s syntax is ridiculous and solves problems that basically don’t exist.

        All of my java/kotlin/rust/etc. code is trivially well formatted and can be done by my editor. Moving code blocks is trivial. Refactoring is easier when I didn’t need to hand -format the code just to make it work.