• Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    18
    ·
    2 days ago

    I can kind of understand it after having to work with an XML file where users encoded data into comments for no good reason. But yeah, it does make JSON awkward for lots of potential use-cases.

    • Ethan@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      22 hours ago

      Anything can be abused. That’s not a legitimate reason to take away perfectly reasonable features. Looking at you, Java (unsigned integers).

      • Ephera@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 hours ago

        Well, I assume they had other concerns, too. For example, it adds a bunch of complexity for reformatting a JSON from single-line to pretty-print, if comments can appear in there. I’m certainly not saying that I’m always best friends with the decision to remove comments, just that I can somewhat understand it.

        • Ethan@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          8 hours ago

          Their stated justification is that people would abuse comments, using them to carry semantic or syntactic information. That’s a shit justification IMO.

          As far as the additional complexity that comments bring, I understand that from a technical perspective but from an engineering-for-real-humans-in-the-real-world perspective that’s the kind of thing you just have to deal with if you want to design a good format.

      • Ephera@lemmy.ml
        link
        fedilink
        English
        arrow-up
        9
        ·
        2 days ago

        They’re not supposed to contain data, but some parsers will allow you to access what’s written into comments. And so, of course, someone made use of that and I had to extract what was encoded basically like that:

        <!--
            Host: toaster,
            Location: moon,
        -->
        <data>Actual XML follows...</data>
        

        My best guess is that they added this data into comments rather than child nodes or attributes, because they were worried some of the programs using this XML would not be able to handle an extension of the format.

        • flying_sheep@lemmy.ml
          link
          fedilink
          arrow-up
          7
          ·
          2 days ago

          That’s why they make sense in code and config files. JSON is neither, despite the insistence of far too many people to write configuration in it.

          • tetris11@feddit.uk
            link
            fedilink
            English
            arrow-up
            5
            ·
            2 days ago

            In an ideal world, yes. In a locked down world where you have access only to 1/4 the codebase or your job is more ontology-focused, all you have access to might be the JSON. Leaving a comment or two about why a particular value or hierarchy is as it is is sometimes more clear than writing up a seperate README that no one will read

    • FooBarrington@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      2 days ago

      This would undoubtedly, unquestionably happen, and it would break JSON. The only reason it works so well is because comments aren’t allowed.