• CoderKat@lemm.ee
      link
      fedilink
      English
      arrow-up
      15
      arrow-down
      1
      ·
      1 year ago

      Ugh, there’s some parts of YAML I love, but ultimately it’s a terrible format. It’s just too easy to confuse people. At least it has comments though. It’s so dumb that JSON doesn’t officially have comments. I’ve often parsed “JSON” as YAML entirely for comments, without using a single other YAML feature.

      YAML also supports not quoting your strings. Seems great at first, but it gets weird of you want a string that looks like a different type. IIRC, there’s even a major version difference in the handling of this case! I can’t remember the details, but I once had a bug happen because of this.

      Performance wise, both YAML and JSON suck. They’re fine for a config file that you just read on startup, but if you’re doing a ton of processing, it will quickly show the performance hit. Binary formats work far better (for a generic one, protobuffers has good tooling and library support while being blazing fast).

      • sonnenzeit@feddit.de
        link
        fedilink
        arrow-up
        8
        ·
        1 year ago

        It’s so dumb that JSON doesn’t officially have comments.

        So much this.

        Used to work at a company where I sometimes had to manually edit the configuration of devices which were written and read in JSON. Super inconvenient if you have to document all changes externally. As a “hack” I would sometimes add extra objects to store strings (the comments). But that’s super dicey as you don’t know if it somehow breaks the parsing. You’re also not guaranteed the order of objects so if the configuration gets read, edited and rewritten your comment might no longer be above/below the change you made.

        Always found it baffling that such a basic feature is missing from a spec that is supposed to cover a broad range of use cases.

      • vrighter@discuss.tchncs.de
        link
        fedilink
        arrow-up
        5
        ·
        1 year ago

        json 5 does support comments. alternatively, yaml is a superset of json. any valid json is also valid yaml. but yaml also supports comments. So you can also write json with comments, and use a yaml parser on it, instead of a standard json parser

    • lhamil64@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      One of these days I’ll actually look up how YAML indentation works. Every time I use it it’s trial and error until I stop getting errors.

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

        That’s a super risky way to do it. It might stop giving you errors because you finally got the indentation right, or it might stop giving you errors because you got the indentation “right” but not how you you meant to organize the objects.