this post was submitted on 24 Jan 2026
61 points (93.0% liked)

Programming

25948 readers
137 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

There exists a peculiar amnesia in software engineering regarding XML. Mention it in most circles and you will receive knowing smiles, dismissive waves, the sort of patronizing acknowledgment reserved for technologies deemed passé. "Oh, XML," they say, as if the very syllables carry the weight of obsolescence. "We use JSON now. Much cleaner."

top 50 comments
sorted by: hot top controversial new old
[–] calliope@retrolemmy.com 35 points 1 month ago* (last edited 1 month ago) (2 children)

There exists a peculiar amnesia in software engineering regarding XML

That’s for sure. But not in the way the author means.

There exists a pattern in software development where people who weren’t around when the debate was actually happening write another theory-based article rehashing old debates like they’re saying something new. Every ten years or so!

The amnesia is coming from inside the article.

[XML] was abandoned because JavaScript won. The browser won.

This comes across as remarkably naive to me. JavaScript and the browser didn’t “win” in this case.

JSON is just vastly simpler to read and reason about for every purpose other than configuration files that are being parsed by someone else. Yaml is even more human-readable and easier to parse for most configuration uses… which is why people writing the configuration parser would rather use it than XML.

Libraries to parse XML were/are extremely complex, by definition. Schemas work great as long as you’re not constantly changing them! Which, unfortunately, happens a lot in projects that are earlier in development.

Switching to JSON for data reduced frustration during development by a massive amount. Since most development isn’t building on defined schemas, the supposed massive benefits of XML were nonexistent in practice.

Even for configuration, the amount of “boilerplate” in XML is atrocious and there are (slightly) better things to use. Everyone used XML for configuration for Java twenty years ago, which was one of the popular backend languages (this author foolishly complains about Java too). I still dread the massive XML configuration files of past Java. Yaml is confusing in other ways, but XML is awful to work on and parse with any regularity.

I used XML extensively back when everyone writing asynchronous web requests was debating between using the two (in “AJAX”, the X stands for XML).

Once people started using JSON for data, they never went back to XML.

Syntax highlighting only works in your editor, and even then it doesn’t help that much if you have a lot of data (like configuration files for large applications). Browsers could even display JSON with syntax highlighting in the browser, for obvious reasons — JSON is vastly simpler and easier to parse.

[–] Kissaki@programming.dev 7 points 1 month ago* (last edited 1 month ago) (1 children)

Making XML schemas work was often a hassle. You have a schema ID, and sometimes you can open or load the schema through that URL. Other times, it serves only as an identifier and your tooling/IDE must support ID to local xsd file mappings that you configure.

Every time it didn't immediately work, you'd think: Man, why don't they publish the schema under that public URL.

[–] calliope@retrolemmy.com 6 points 1 month ago* (last edited 1 month ago)

This seriously sounds like a nightmare.

It’s giving me Eclipse IDE flashbacks where it seemed so complicated to configure I just hoped it didn’t break. There were a lot of those, actually.

load more comments (1 replies)
[–] epyon22@sh.itjust.works 25 points 1 month ago (1 children)

The fact that json serializes easily to basic data structures simplifies code so much. Most use cases don't need fully sematic data storage much of which you have to write the same amount of documentation about the data structures anyways. I'll give XML one thing though, schemas are nice and easy, but high barrier to entry in json.

[–] Kissaki@programming.dev 7 points 1 month ago (2 children)

Most use cases don’t need fully sematic data storage

If both sides have a shared data model it's a good base model without further needs. Anything else quickly becomes complicated because of the dynamic nature of JSON - at least if you want a robust or well-documented solution.

[–] SlurpingPus@lemmy.world 4 points 1 month ago (1 children)

If both sides have a shared data model

If the sides don't have a common understanding of the data structure, no format under the sun will help.

load more comments (1 replies)
[–] sukhmel@programming.dev 3 points 1 month ago

Yeah, when the same API endpoint sometimes return a string for an error, sometimes an object, and sometimes an array, JSON doesn't help much in parsing the mess

[–] Feyd@programming.dev 20 points 1 month ago* (last edited 1 month ago)

Honestly, anyone pining for all the features of XML probably didn't live through the time when XML was used for everything. It was actually a fucking nightmare to account for the existence of all those features because the fact they existed meant someone could use them and feed them into your system. They were also the source of a lot of security flaws.

This article looks like it was written by someone that wasn't there, and they're calling people telling them the truth that they are liars because they think features they found in w3c schools look cool.

[–] Diplomjodler3@lemmy.world 18 points 1 month ago (1 children)

It's true, though, that JSON is just better for most applications.

[–] MonkderVierte@lemmy.zip 10 points 1 month ago (7 children)

Except config files. Please don't do config files in json.

[–] abbadon420@sh.itjust.works 4 points 1 month ago (1 children)
[–] atzanteol@sh.itjust.works 8 points 1 month ago

Fuck yaml. TOML or literally anything else.

[–] Diplomjodler3@lemmy.world 2 points 1 month ago (1 children)

Why not? It works great in Python.

[–] MonkderVierte@lemmy.zip 6 points 1 month ago (2 children)

Not on the human parser side.

[–] Tanoh@lemmy.world 5 points 1 month ago (1 children)

And no comments, unless you use a non-standard parser. But then you might as well use anorher format.

[–] Diplomjodler3@lemmy.world 5 points 1 month ago* (last edited 1 month ago) (5 children)
{"comment": "Who says you can't do comments in JSON?"}
[–] abbadon420@sh.itjust.works 6 points 1 month ago

Lol. That works, but its hacky.

The meaning of a "comment" is an integrated language feauture to write something that is not parsed by that language. This is just regular JSON.

[–] bleistift2@sopuli.xyz 2 points 1 month ago

This only works if the software that consumes the JSON doesn’t validate it or ignores keys it doesn’t recognize (which is bad, IMHO).

load more comments (3 replies)
[–] atzanteol@sh.itjust.works 2 points 1 month ago (2 children)

JSON is super easy to read and write though. Just needs a parser that allows comments...

load more comments (2 replies)
load more comments (5 replies)
[–] AnitaAmandaHuginskis@lemmy.world 14 points 1 month ago* (last edited 1 month ago) (1 children)

I love XML, when it is properly utilized. Which, in most cases, it is not, unfortunately.

JSON > CSV though, I fucking hate CSV. I do not get the appeal. "It's easy to handle" -- NO, it is not. It's the "fuck whoever needs to handle this" of file "formats".

JSON is a reasonable middle ground, I'll give you that

[–] unique_hemp@discuss.tchncs.de 8 points 1 month ago (4 children)

CSV >>> JSON when dealing with large tabular data:

  1. Can be parsed row by row
  2. Does not repeat column names, more complicated (so slower) to parse

1 can be solved with JSONL, but 2 is unavoidable.

[–] entwine@programming.dev 3 points 1 month ago* (last edited 1 month ago) (1 children)
{
    "columns": ["id", "name", "age"],
    "rows": [
        [1, "bob", 44], [2, "alice", 7], ...
    ]
}

There ya go, problem solved without the unparseable ambiguity of CSV

Please stop using CSV.

[–] unique_hemp@discuss.tchncs.de 2 points 1 month ago (1 children)

Great, now read it row by row without keeping it all in memory.

load more comments (1 replies)
load more comments (3 replies)
[–] lehenry@lemmy.world 8 points 1 month ago (4 children)

While I understand the critic about XPath and XSL, the fact that we have proper tools to query and tranform XML instead of the messy wat of getting specific information from JSON is also one of tge strong point of XML.

[–] deadbeef79000@lemmy.nz 7 points 1 month ago

XSLT and XPath are entirely underrated. They are seriously powerful tools.

While you can approximate XSLT with a heap of coffee and a JSON parser it's harder to keep it declarative.

load more comments (3 replies)
[–] pinball_wizard@lemmy.zip 7 points 1 month ago* (last edited 1 month ago) (2 children)

When you receive an XML document, you can verify its structure before you ever parse its content. This is not a luxury. This is basic engineering hygiene.

This is actually why my colleagues and I helped kill off XML.

XML APIs require extensive expertise to upgrade asynchronously (and this expertise is vanishingly rare). More typically all XML endpoints must be upgraded during the same unscheduled downtime.

JSON allows unexpected fields to be added and ignored until each participant can be upgraded, separately and asynchronously. It makes a massive difference in the resilience of the overall system.

I really really liked XML when I first adopted it, because before that I was flinging binary data across the web, which was utterly awful.

But XML for the web is exactly where it belongs - buried and forgotten.

Also, it is worth noting that JSON can be validated to satisfy that engineering impulse. The serialize/deserialize step will catch basic flaws, and then the validator simply has to be designed to know which JSON fields it should actually care about. This gets much more resilient results than XMLs brittle all-in-one shema specification system - which immediately becomes stale, and isn't actually correct for every endpoint, anyway.

The shared single schema typically described every requirement of every endpoint, not any single endpoint's actual needs. This resulted in needless brittleness, and is one reason we had such a strong push for "microservices". Microservices could each justify their own schema, and so be a bit less brittle.

That said, I would love a good standard declarative configuration JSON validator, as long as it supported custom configs at each endpoint.

load more comments (2 replies)
[–] entwine@programming.dev 4 points 1 month ago

I agree with everything this article said. A lot of software would work better if devs took the time to learn and appreciate XML. Many times I've found myself reinventing shit XML gives you for free.

...But at the same time, if I'm working on a developer-facing product of any kind, I know that choosing XML over JSON is going to turn a lot of people away.

[–] A_norny_mousse@feddit.org 4 points 1 month ago* (last edited 1 month ago) (3 children)

I never understood why people would say JSON is superior, and why XML seemed to be getting rarer, but the author explains it:

XML was not abandoned because it was inadequate; it was abandoned because JavaScript won.

I've been using it ever since I started using Linux because my favorite window manager uses it, and because of a long-running pet project that is almost just as old: first I used XML tools to parse web pages, later I switched to dedicated data providers that offered both XML and JSON formats, and stuck to what I knew.

I'm guessing that another reason devs - especially web devs - prefer JSON over XML is that the latter uses more bytes to transport the same amount of raw data. One XML file will be somewhat larger than one JSON file with the same content. That advantage is of course dwarved by all the other media and helper scripts - nay, frameworks, devs use to develop websites.

BTW, XML is very readable with syntax highlighting and easily editable if your code editor has some very basic completion for it. And it has comments!

[–] Kissaki@programming.dev 3 points 1 month ago

The readability and obviousness of XML can not be overstated. JSON is simple and dense (within the limit of text). But look at JSON alone, and all you can do is hope for named fields. Outside of that, you depend on context knowledge and specific structure and naming context.

Whenever I start editing json config files I have to be careful about trailing commas, structure with opening and closing parens, placement and field naming. The best you can do is offer a default-filled config file that already has the full structure.

While XML does not solve all of it, it certainly is more descriptive and more structured, easing many of those pain points.


It's interesting that web tech had XML in the early stages of AJAX, the dynamic web. But in the end, we sent JSON through XMLHttpRequest. JSON won.

load more comments (2 replies)
[–] schnurrito@discuss.tchncs.de 4 points 1 month ago

XML is best suited for storing documents, JSON for transmitting application data over networks.

SVG is an example of an excellent use of XML, it doesn't mean we should use XML for transmitting data from a backend to a frontend.

[–] erebion@news.erebion.eu 3 points 1 month ago

XMPP shows pretty well that XML can do things that cannot be done easily without it. XMPP wouldn't work nearly as well with JSON. Namespaces are a super power.

[–] TunaLobster@lemmy.world 2 points 1 month ago (1 children)

IMO, the best thing about YAML is the referencing. It's super easy to reuse an object multiple times. Gives that same kind of parten child struct ability that programming languages have. Sure XML can do it, but it's not in every parser. cough python built in parser cough But then YAML is also not a built in parser and doing DOM in things other than XML feels odd.

[–] Feyd@programming.dev 4 points 1 month ago

That capability is what enables billion laugh attacks, unfortunately, so not having it enabled in cases where there is external input possible is wise

[–] Auster@thebrainbin.org 2 points 1 month ago (3 children)

Skimming through the post, the code snippet about halfway through picked my attention. Been a while since I studied site development, but that snippet looks awfully like HTML. Are it and XML related?

[–] A_norny_mousse@feddit.org 6 points 1 month ago (1 children)

Yes. Arguably, HTML is a form of XML. Also, the ML means the same in both. XML tools can often also be used to query HTML documents.

[–] Auster@thebrainbin.org 2 points 1 month ago

Ooooh~

Thanks for the explanation!

[–] Kissaki@programming.dev 5 points 1 month ago* (last edited 1 month ago) (1 children)

There was a time where HTML moved towards a more formalized XML-valid definition named XHTML. Ultimately, web/browser backwards compatibility and messy and forgiving nature lead to us giving up on that and now we have the HTML living standard with rules, but browsers (not sure to what degree it's standardized or not) are very forgiving in their interpretation.

While HTML, prior to HTML5, was defined as an application of Standard Generalized Markup Language (SGML), a flexible markup language framework, XHTML is an application of XML, a more restrictive subset of SGML. XHTML documents are well-formed and may therefore be parsed using standard XML parsers, unlike HTML, which requires a lenient, HTML-specific parser.[1]

XHTML 1.0 became a World Wide Web Consortium (W3C) recommendation on 26 January 2000. XHTML 1.1 became a W3C recommendation on 31 May 2001. XHTML is now referred to as "the XML syntax for HTML"[2][3] and being developed as an XML adaptation of the HTML living standard.[4][5]

[–] MonkderVierte@lemmy.zip 2 points 1 month ago* (last edited 1 month ago)

But nobody uses it anymore and uses a js-framework on a page instead. Which only 3 billion-dollar engines in the world can render.

[–] atzanteol@sh.itjust.works 5 points 1 month ago* (last edited 1 month ago)

They're siblings. They both derive from SGML. There is a version of HTML that is also XML conformant called XHTML but it never caught on...

load more comments
view more: next ›