3 ms·
You have to use the right tool for the job. XML is extensible markup, i.e. it's like HTML that can be applied to tasks outside of representing web pages. It's
by zarzavat 9mo ago
You have to use the right tool for the job.
XML is extensible markup, i.e. it's like HTML that can be applied to tasks outside of representing web pages. It's designed to be written by hand. It has comments! A good use for XML would be declaring a native UI: it's not HTML but it's like HTML.
JSON is a plain text serialization format. It's designed to be generated and consumed by computers whilst being readable by humans.
Neither is a configuration language but both have been abused as one.
- ahf8Aithaex7Nai 9mo ago> It's designed to be written by hand Are you sure about that? I've heard XML gurus say the exact opposite. This is a very good example of why I detest the phrase “use the right tool for the job.” People say this as an appeal to reason, as if there weren't an obvious follow-up question that different people might answer very differently.
- zarzavat 9mo agoPerfectly sure. XML is eXtensible Markup Language, the generalized counterpart to Hypertext Markup Language. XML, HTML, SGML are all designed to be written by hand. You can generate XML, just like you can generate HTML, but the language wasn't designed to make that easy. Computers don't need comments, matching </end> tags, or whitespace stripping. There was a time, in the early-mid 2000s when XML was the hammer for every screw. But then JSON was invented and it took over most of those use cases. Perhaps those XML gurus are stuck in a time warp. XML remains a good way to represent tree structures that need to be human editable.
- unscaled 9mo agoSGML was designed for documents, and it can be written by hand (or by a machine). HTML (another descendant of SGML) is in fact written by hand regularly. When you're using SGML descendants for what they were meant for (documents) they're pretty good for this purpose. Writing documents — not configuration files, not serialized data, not code — by hand. XML can still be used as a very powerful generic document markup language, that is more restricted (and thus easier to parse) than SGML. The problems started when people started using XML for other things, especially for configuration files, data interchange and even for programming language. So I don't think GP is wrong. The authors of the original XML spec probably envisioned people writing this by hand. But XML is very bad for writing by hand the things that it eventually got used for.
- locknitpicker 9mo ago> It's designed to be written by hand. This assertion is comically out of touch with reality, particularly when trying to describe JSON as something that is merely "readable by humans". You could not do anything at all with XML without having to employ half a dozen frameworks and tools and modules.
- g-b-r 9mo agoYou can do everything you can do with JSON by just knowing the basic syntax (<element attribute=""></element>). The complexity about XML comes from the many additional languages and tools built on top of it. Many are too complex and bloated, but JSON has little to nothing comparable, so it's only simple because it doesn't support what XML does.
- ahf8Aithaex7Nai 9mo ago> The complexity about XML comes from the many additional languages and tools built on top of it. It's not just that, is it? There are also attributes versus child elements, dealing with white space including the xml:space attribute, namespaces, schemas, integration of external document fragments with xinclude:include or &extern;. Each of these is a huge can of worms in its own right. There are probably more that I'm not even aware of right now. A few years ago, I wrote a fully functional parser for JSON that is easy to verify for correctness and that isn't just lying around somewhere as a toy, but is actually used (by me) in various projects time and again. Overall, building this parser was almost trivial. With XML, I'm not even sure I would be able to write a correct and complete parser. But I agree with you that XML-based languages and XML tools make things even worse. I had to work with XML a lot over ten years ago. I still get annoyed when I think about XSLT, or dealing with schemas, or the challenge of finding usable tools that are reasonably compliant with standards. You can only have a positive view of XML when you think of something like this: <?xml version="1.0" encoding="UTF-8"?> <booklist> <book> <title>Example Book</title> <author>Max Mustermann</author> <year>2025</year> </book> <book> <title>Second Book</title> <author>Erika Musterfrau</author> <year>2026</year> </book> </booklist> And at that level, I have (almost) no problem with XML. But as soon as things get more demanding and you really take the various aspects of XML's value proposition seriously, you enter a world of pain and despair. At least, that's how it was for me back then. Maybe I would see things differently today, but I'm not really interested in finding out.