Live data from Hacker News

Do you hate XML? (2010)

sigfrid-lundberg.se

51–60 of 99 posts

Re: Do you hate XML? (2010)

#51
post #41
post #18

Earlier quoted context omitted.

Not really. In C# I use a parsing library for which I just write a class and then the library automatically serializes the JSON into an instance of that class. I can do the same thing with XML. Of course it doesn't necessarily go that smoothly with all xml, but as long as the xml is fairly simple like a JSON document would be it's totally fine. It's only when you start to use all the features of xml that don't fit ne…

I would even go as far to say that XML may very well be better in some cases, - here you have a schema most of the time, so you can often catch e.g. schema evolution failures at compile time. This is much less common/less standardized with json.

JSON schema exists. If you restrict yourself to a sensible subset of XML features in your XML schema, you can have a 1:1 correspondence to JSON and JSON Schema. We do that at work. Due to historical reasons we have a XSD but provide the complimentary JSON Schema to those who wish to send us JSON.

The JSON is converted on the fly to XML based on the XSD so it can be ingested by our existing XML integration. Similar with return answers, response XMLs are converted on the fly based on the XSD to JSON.

JSON endpoints validate against the JSON Schema, also generated from the XSD at runtime, XML against the XSD of course.

We had a diverse set of XSDs but didn't have to tweak them to support JSON. We used restrictions and extensions, both simple and complex, we used min/max, enums, descriptions and examples and more, so not entirely boring XSDs.

We did establish some conventions, attributes turns the child element to an object and the attributes become properies, just simple stuff like that.

This way customers can hand us what they prefer generating and ingesting, and we don't have to worry about keeping two different schemas for the same endpoint in sync.

Re: Do you hate XML? (2010)

#52
post #37

I dislike it because it failed in such a fundamental way as a way to represent a document; you cannot, in general, reliably determine what characters the bytes in an XML file represent - the best a general XML processor can do is guess.

[deleted]

Re: Do you hate XML? (2010)

#53
post #24
post #13

Earlier quoted context omitted.

I don't like HTML5 and to this day I don't understand what was actually gained by dropping XHTML.

XHTML was dropped because it wasn’t backwards compatible, and it was too strict in its syntax. Minor syntax errors that could be automatically corrected by the browser turned into full page errors.

Meanwhile valid XHTML like having custom elements as table children, in HTML gets silently "corrected" to an malformed document.

I'd much rather have the stricter syntax parsing of XML, vs the complex and outdated structural correction rules of HTML.

Re: Do you hate XML? (2010)

#54
post #37

I dislike it because it failed in such a fundamental way as a way to represent a document; you cannot, in general, reliably determine what characters the bytes in an XML file represent - the best a general XML processor can do is guess.

[deleted]

Re: Do you hate XML? (2010)

#55
post #36

XML was a good, well-intentioned idea. The problem, IMHO, was that rampant "xml-abuse" in the naughts. ws-* standards and over-engineered garbage like SOAP ("complex object access protocol") made people loathe XML. I did like JAXB in Java, XLST, schemas, XPATH. Never got into XSL, but it seemed like good thing too. It worked best when your tooling manipulated it for you or at least helped you in an intelligent way. M…

It's non-trivial to implement XML parser in a secure way, many stdlib ones are insecure by default. That should just not be a thing. XML has a bunch of vulnerabilities very specific to it, XXE is the most well known one, but you also have a bunch of DoSes due to expansions and XPath injection etc. An object serialization format should not have a bunch of footguns and vulnerability categories specific to it.

The funny thing is that JSON parsing is usually kinda unsafe in it's main target language JavaScript, and usually safe in other languages, because of the `__proto__` prototype pollution.

Re: Do you hate XML? (2010)

#56
post #48

Earlier quoted context omitted.

1. What, in your view, are the right reasons to hate XML? 2. To me, verbosity and aesthetics seem like perfectly valid reasons to hate XML. Once you learn S expressions, XML looks disgusting . They implemented half of Common Lisp in a markup language.

> They implemented half of Common Lisp in a markup language Come on, S expressions are just trees, they are not God's gift to humankind.. and just because a language has an AST (surprise, a tree again!) doesn't make it a lisp. I can write a C program's AST as sexprs or a Haskell program's, yet neither will be a lisp.

S expressions are just trees. XML is just trees. But S expressions are much less verbose trees. Once you see that they're both trees, then XML looks disgustingly verbose.

XSLT is what I meant by "half of common Lisp". It's probably an exaggeration, but once you can use XML to transform XML trees into other XML trees...

Re: Do you hate XML? (2010)

#57
post #20
post #13

Earlier quoted context omitted.

I don't like HTML5 and to this day I don't understand what was actually gained by dropping XHTML.

Not having the page break because of a small mistake. Though I did get pretty good at writing XHTML, and strictness is a blessing in certain cases.

Fail fast is a feature, not a bug. It's much better to get clear and actionable feedback rather than the page silently rendering incorrectly in some subtle manner.

Re: Do you hate XML? (2010)

#58
post #15

XML is unfairly maligned. Yes, people bought into it too much 26 years ago, but then you would too if you had to maintain someone else's massive packed struct dumped into a file and documented in a poorly-maintained word document --- or worse, a brace of dumb IETF RFCs that contradict eachother. I am glad that younger generations are looking at it with fresh eyes. XML is a useful format; it has its place in your tool…

XML wasn’t the best alternative then either. S-expressions have been around since the 50s and are better than either XML or JSON.

Re: Do you hate XML? (2010)

#59
post #17

I’ve hated XML since 2004. The worst part about it is the tags vs attributes fights. They both do the same thing and the only difference is preference. Having two ways of doing the same thing invite and incite religious positions and cause unnecessary fighting. There should be one, opinionated way of doing things so you avoid confusion.

> The worst part about it is the tags vs attributes fights. They both do the same thing and the only difference is preference. They're not the same thing. If you look at it as the extensible markup language for documents that it is, "tags" (i.e. inner content) would be visible and "attributes" would not. If your XML document was processed by an application to convert to another type of document (PDF, etc.), and it di…

> If you look at it as the extensible markup language for documents that it is, "tags" (i.e. inner content) would be visible and "attributes" would not.

  

Re: Do you hate XML? (2010)

#60
post #2

In my opinion, the reason people hate XML is because of what M signifies: it is a markup language and most of the time we don’t need a markup language. Markup languages are great for rich text documents. They are just not a good fit for representing data. The markup-nature of XML introduces unnecessary choice in whether to use an attribute or a child element to represent data; for HTML such ambiguity doesn’t actually…

YAML made me not hate XML.

[deleted]
Post reply on HN