• blackstrat@lemmy.fwgx.uk
    link
    fedilink
    arrow-up
    36
    arrow-down
    19
    ·
    11 days ago

    XML is a superior format to Json or yaml or any of those other trendy formats around today. It’s the hill I’m willing to die on because I’m right.

    • anyhow2503@lemmy.world
      link
      fedilink
      arrow-up
      71
      arrow-down
      3
      ·
      11 days ago

      XML aims to be both human-readable and machine-readable, but manages neither. It’s only really worth it if you actually need the complexity or extensibility, otherwise it’s just a major pain to map XML structures to any sensible type representation. I’ve been forced to work with some of the protocols that people like to present as examples of good XML usage and I hate every single one of them.

      Fuck YAML though. That spec is longer and more complex than any other markup language I know of and it doesn’t have a single fully compliant implementation.

      • corroded@lemmy.world
        link
        fedilink
        arrow-up
        23
        arrow-down
        1
        ·
        11 days ago

        I’m okay with the “human-readability,” but I’ve never been happy with the “machine-readibility” of XML. Usually I just want to pull a few values from an API return, yet every XML library assumes I want the entire file in a data structure that I can iterate through. It’s a waste of resources and a pain in the ass.

        Even though it’s not the “right” way, most of the time I just use regex to grab whatever exists between an opening and closing tag. If I’m saving/loading data from my own software, I just use a serialization library.

        • Chris@feddit.uk
          link
          fedilink
          English
          arrow-up
          8
          arrow-down
          1
          ·
          11 days ago

          Yep, it’s a PITA to parse and get the values you want. Much prefer JSON. Recently when I needed to parse XML I ran it through an XML to JSON library. Much easier!

          If you need to parse XML just for RSS though, it isn’t so bad as there are RSS specific libraries which take most of the pain away.

          • corroded@lemmy.world
            link
            fedilink
            arrow-up
            4
            arrow-down
            1
            ·
            10 days ago

            I appreciate the suggestion, but that looks like a Java library. Interpreted languages make me feel dirty. Java makes me feel even dirtier. If it’s not C, C++, or ASM, is it really worth using?

            • MagicShel@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              10 days ago

              Idk. Been doing it for nearly 20 years and before that I was doing IBM’s take on VBScript for another 10. So I have my own perspective there. I’ve only ever had to parse massive xmls when doing web apps, and for web backends I really only like Java and NodeJS.

              But everyone is entitled to their own take. I would imagine there is a streaming parser in other languages as well.

      • GTG3000@programming.dev
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        9 days ago

        Yeah, I remember when I was trying to parse XML into some lua tables and it forever stumped me how to represent something like

        <thing important_param=10 other_param="abracadabra"> stuff </thing>
        

        You just have to have different ways to turn different tags into stuff in your program and that’s a huge amount of overhead to think about when all I want is a hash map and maybe an array.

    • Chris@feddit.uk
      link
      fedilink
      English
      arrow-up
      17
      arrow-down
      1
      ·
      11 days ago

      I can only assume you’ve never tried to parse or read XML.

      • key@lemmy.keychat.org
        link
        fedilink
        English
        arrow-up
        13
        ·
        10 days ago

        Something being “old” is totally unrelated to whether it’s trendy. See: virtually every food and fashion trend.

    • redfellow@sopuli.xyz
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      10 days ago

      As someone who works with both, readability is the utmost important thing for me, and XML is cumbersome and has more characters to sift through to find what I’m lookin for.

    • banshee@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      10 days ago

      I don’t miss XML, but at least it has support for comments. On the other hand, I wish whitespace in XML wasn’t significant. JSON needs to die in favor of JSON 5.

    • Moldy@lemmy.zip
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      9 days ago

      Nah, XML is just a slightly older fad. Let’s go back to S Expressions. They’ve been in use for over 60 years and have significantly better readability.