Live data from Hacker News

You probably misunderstand XML

lemire.me

11–20 of 31 posts

Re: You probably misunderstand XML

#11
post #5

Thumbs down. He taught an entire course on XML, which he calls a "great meta-example on how to deal with semi-structured data"? And his only defense of XML over JSON is... it's worked ok for some file formats? The only point in this whole article is that XML is not well-suited for RPCs, though he fails to argue that it's well-suited for anything else. One argument is that XML is better than JSON for use cases like XH…

"I get the feeling XML wasn't really made for this case, though, it was made for the JSON-like case."

Back in 1997, XML was "SGML for the Web." It was a way to pass around structured, plain-text, human-readable documents that did not require expensive, buggy, incomplete parsers.

It then got misapplied as an RPC transport encoding, and tools vendors were more than happy to start pushing specs, such as W3C Schemas, that demanded the use of tools.

It started out to be simple, but, as things happen, got hijacked. But the fault is with the misapplication, not XML itself.

Re: You probably misunderstand XML

#12
My biggest issue with XML is "XML misunderstands Unix philosophy". You can't easily use cut, awk and grep with XML without having a million of edge case to handle. There are some tools like XMLStarlet, xsltproc or xalan. But you can't safely extract content from XML files with standards tools even if you use the XML extension for gawk.

You could argue that XML documents are complex and cannot be described using simple comma separated. Maybe but some many XML documents are just there to store simple key,value data.

And now, we have "jsawk" (https://github.com/micha/jsawk) for parsing JSON under your terminal...

Re: You probably misunderstand XML

#14
post #10

As Tim Lister once said, if everybody's getting it wrong, there's something wrong with it .

That's a cop-out. You really have to define "everybody."

I know a guy who deployed a Java application on servers with 64MB of memory, and he did it back before the JIT compiler was any good. It was performant and got the job done. He's not unique: lots of performant Java applications were built on hardware that was tiny compared to today's hardware. But for some reasonable meaning of "everybody," everybody writes horrible bloated Java code that requires costly hardware to run.

I've used simple, practical XML web services -- in fact, we have several running at work, and when adding or changing functionality, dealing with the XML aspect is a rounding error compared to implementing the application logic. But for some reasonable meaning of "every," everybody writing enterprise XML web services creates overengineered, overcomplex, finicky interfaces that require ongoing error-prone tweaking of DOM or SAX code.

Sometimes when everybody's getting it wrong, that just means "it" has proved irresistible to stupid people and PHBs. It doesn't mean a sensible, tasteful engineer won't be able to use it correctly. Ditching a technology because stupid people love to misuse it may be a good fashion choice, and it may have a good way to influence hiring if you don't have more direct influence, but there's no engineering justification for it.

And don't forget that for some reasonable meaning of "everybody," everybody who has tried Lisp programming has become horribly lost and failed to accomplish anything with it. (This may be less true since Lisp is rarely taught in colleges nowadays, but it was true at some point in time.)

Re: You probably misunderstand XML

#16
post #12

My biggest issue with XML is "XML misunderstands Unix philosophy". You can't easily use cut, awk and grep with XML without having a million of edge case to handle. There are some tools like XMLStarlet, xsltproc or xalan. But you can't safely extract content from XML files with standards tools even if you use the XML extension for gawk. You could argue that XML documents are complex and cannot be described using simpl…

xsl and transforms are what you use to extract data from xml. xslt is the coolest thing about xml IMHO.

the only real complaint I have is that xsl, being itself xml, is pretty verbose and can be tedious to write.

Re: You probably misunderstand XML

#17
post #5

Thumbs down. He taught an entire course on XML, which he calls a "great meta-example on how to deal with semi-structured data"? And his only defense of XML over JSON is... it's worked ok for some file formats? The only point in this whole article is that XML is not well-suited for RPCs, though he fails to argue that it's well-suited for anything else. One argument is that XML is better than JSON for use cases like XH…

I don't agree at all. Mixed content was once the primary use case for XML. XML and SGML before it was made for marking up documents and documents contain mixed content. They're not databases and they're not message formats containing structured data.

Re: You probably misunderstand XML

#18
post #9
post #5

Thumbs down. He taught an entire course on XML, which he calls a "great meta-example on how to deal with semi-structured data"? And his only defense of XML over JSON is... it's worked ok for some file formats? The only point in this whole article is that XML is not well-suited for RPCs, though he fails to argue that it's well-suited for anything else. One argument is that XML is better than JSON for use cases like XH…

The only good point for XML is there are existing tools that do things via XML. There are tools that generate ATOM and RSS for you. And there are tools that consume ATOM and RSS. So if XML is already a well defined and followed standard for what you want do, use XML. In all other situations use something else.

Then help me translate this into JSON please

How about that way:

{tag: "p", class: "content", text: ["Then help me translate this into ", {tag: "span", class: "highlight", text: "JSON"}, " please"]}

And that's just a small example where you can see all the start and end tags on one screen. Now change the example to insert a hyperlink, say, around the word "help". How easy is it to change?

Re: You probably misunderstand XML

#19
post #16
post #12

My biggest issue with XML is "XML misunderstands Unix philosophy". You can't easily use cut, awk and grep with XML without having a million of edge case to handle. There are some tools like XMLStarlet, xsltproc or xalan. But you can't safely extract content from XML files with standards tools even if you use the XML extension for gawk. You could argue that XML documents are complex and cannot be described using simpl…

xsl and transforms are what you use to extract data from xml. xslt is the coolest thing about xml IMHO. the only real complaint I have is that xsl, being itself xml, is pretty verbose and can be tedious to write.

xslt is beyond tedious, it is infuriating. There are few use cases for xslt that would not be better served with a procedural technique, eg. python and a parser.

also the whole "using xml to define a transformation on some other xml" thing is so overly meta as to induce a massive brain hemorrhage out of my nose and all over my desk.

Re: You probably misunderstand XML

#20
post #16

Earlier quoted context omitted.

xsl and transforms are what you use to extract data from xml. xslt is the coolest thing about xml IMHO. the only real complaint I have is that xsl, being itself xml, is pretty verbose and can be tedious to write.

xslt is beyond tedious, it is infuriating. There are few use cases for xslt that would not be better served with a procedural technique, eg. python and a parser. also the whole "using xml to define a transformation on some other xml" thing is so overly meta as to induce a massive brain hemorrhage out of my nose and all over my desk.

Fortunately you can now use XPath for simple queries and XQuery beyond that.
Post reply on HN