News for hackers. Stuff that matters.
Re:OPML Is Underrated by ChrisMarshallNY on Saturday February 10, 2024 @07:09AM (#39325573)
I’ve never liked XML, per se, but I used it extensively, for decades, and even got fairly good with it.

These days, I mostly use JSON, but XML is pretty much an ironclad data definition and transfer protocol. You can define and transfer just about any type of data, using it, albeit, in a rather “prolix” manner.

Re:OPML Is Underrated by ambigious7777 on Saturday February 10, 2024 @11:29AM (#39327448)
XML is such a versatile format, and I wished it was used so much more. It doesn't have exactly the cleanest syntax, but it would be so much better than JSON in some of the cases I've seen. Especially when you are transfering document-type data. Why use JSON to represent rich text, when XML is infinitely better?
Re:OPML Is Underrated by cryptonector on Saturday February 10, 2024 @05:53PM (#39330969)
> but XML is pretty much an ironclad data definition and transfer protocol.

I suspect that may be why you might not have liked it. XML is not a good serialization of data for network protocols. XML is a good serialization of documents. Ok, that's the received wisdom that I'm echoing, but it's also my experience and my opinion.

When it comes to serialization of data for network protocols there are and have been many other better-suited schemes. XML got used as a serialization protocol for the the web because it's what existed at the time that was... close to HTML and textual, but it's got the disadvantage of being verbose.

Re:OPML Is Underrated by ChrisMarshallNY on Saturday February 10, 2024 @08:35PM (#39331912)
Yes and no. You are correct about it being a document protocol, but it has long been set up as a big document protocol.

Most XML parsers are structured to parse and deliver XML in element-delimited packets, in asynchronous fashion. I don't know of many JSON parsers that can do the same. They do exist (I use one, in the backend of one of my projects[0]), but they aren't as common. XML has packet/async built into OS SDKs, but JSON tends to be "The Whole Nine Yards" handling.

With Big Data/ML, I'm surprised that this is still a thing.

[0] https://github.com/salsify/jsonstreamingparser

Re:OPML Is Underrated by cryptonector on Saturday February 10, 2024 @11:38PM (#39332682)
> but it has long been set up as a big document protocol.

[Meaning stream parsing.] Yes, but typically one does not need that for small messages. I see that streaming decoders for Protocol Buffers is a thing now, but historically one does not bother with streaming for small messages, instead one streams lots of small messages.

> I don't know of many JSON parsers that can do the same.

libjq has one. With jsonlines or similar, if each text is small, there's no need for streamed decoding. Typically a DB query will produce a sequence of lots of small JSON texts, not one very large one.

If you're updating a DOM from XML then stream decoding makes sense, but in many cases streaming isn't ergonomic, just necessary when dealing with large documents (e.g., if there's not enough memory to hold them in memory without thrashing).