• SavvyWolf
    link
    English
    228 months ago

    You know, at this point I’ve been writing YAML on and off for a while now. You’d think I actually understand the syntax by now, but I don’t.

    • @ApexHunter@lemmy.ml
      link
      fedilink
      78 months ago

      That’s because it is absolutely terrible. It is the first serious/real “language” I have encountered since Cobol where indent level has functional meaning. This is not good company to be in.

        • GTG3000
          cake
          link
          fedilink
          88 months ago

          Python has stricter rules about what can be cludged together and how.

          Yaml is… Kind of nebulous, which is not a good thing for a data serialization format.

          • @KrokanteBamischijf@feddit.nl
            link
            fedilink
            18 months ago

            Yeah not a fan of YAML either. I simply don’t see the benefit of getting rid of delimiters and replacing them with indentation. Yes, it does save several bytes, which might be important if you measure space in kilobytes I guess. It does provide cleaner files which may or may not be more readable.

            It does not provide any advantages in parsing complexity. It does not provide any protection against typos.

            I guess the same can be said of python, which forces indentation and therefore readable code formatting. Which is a problem that does not exist since the invention of code formatters and linters.

            I like python for what it does but delimiters are actually useful in terms of readability. They provide an extra hint that the text you’re about to look at conforms to a specific structure.

            • GTG3000
              cake
              link
              fedilink
              17 months ago

              Oh god, parsing complexity. I actually tried writing a YAML parser in my free time before and boy was that not worth the headache. So many little things that complicate parsing and are ignored by majority of users!

              I really like python, but I can agree that it’s no-delimiters style can be… Confusing at times. I definitely had to hunt down bugs that were introduced by wrong indentation. That and the way it handles global/local variables, mostly.

              I do appreciate not having to enclose every key in “”, and being able to copy values - but if we want that kind of logic making our configs, why not just switch to writing configurations in Lua? It certainly has less footguns than YAML and it has the niceties like “I can just write {key = "value"} instead of {"key": "value"}”.

              • @KrokanteBamischijf@feddit.nl
                link
                fedilink
                17 months ago

                Honestly that probably goes for any interpreted programming language that supports imports.

                Many Javascript frameworks just put their configuration into -.config.js files in the project root. Which is a pretty elegant solution that does not require custom parsing. Just import the config and go nuts.

                Compiled (and by extension bundled) software obviously requires a different approach, but at that point you should probably consider storing your config in some kind of database.

                Maybe there just isn’t a right answer to the config conundrum if all the general solutions are janky in some way.

                • GTG3000
                  cake
                  link
                  fedilink
                  17 months ago

                  Well, there’s a few things I personally think are a must for a config format:

                  1. It must be human readable and editable, in some way. - in many cases, you may want to go and change something in the config while the application proper isn’t running. That rules out stuff like pickle or binary formats. Although I suppose sqlite and it’s ilk still fulfill it, in a roundabout way.
                  2. It should be unambiguous, with one way to do something right. - this one’s a doozie. JSON fulfills it since it’s unambiguous about it’s types, but many interpreted language configs will have options. And then YAML will have “no” turn into “false”.
                  3. It should probably have comments. - handily failed by standard JSON implementations. Although to be fair a lot of parsers I’ve used understand comments. Or you can make a comment stripper real easily.
                  4. It should have obvious structure. - I’ve dealt with CSV configs before, I do not want to ever again.