Live data from Hacker News

How to Avoid Being Called a Bozo When Producing XML (2005)

hsivonen.fi

41–50 of 255 posts

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#41
post #17

Why would anyone choose to use XML over JSON, other than for RSS?

I'll add some more reasons to the flamebait: - JSON doesn't have namespaces, making integration of different data-sources quite hard. - XML allows me to do versioning within documents. - An extremely large corpus of well-tested libraries are available. - As opposed to JSON, XML and accompanying standards (XSLT, XML Schema, XPath, XQuery) are extremely well documented. - XML validation, parsing and processing can happ…

> - JSON doesn't have namespaces, making integration of different data-sources quite hard.

The only reason anyone would ever say that is ... that they have used XML (or SGML) and are subscribed to that mindset.

Every toplevel JSON document is a valid value in any other JSON document. That's how easy it is to integrate. The only reason that XML/SGML needs namespaces in the first place is that the schema dictates what an element, e.g. , can have as children or attributes, and how many -- and as a result, from a programming language and from a city design schema cannot be mixed (neither would be valid in the other's schema). So you have to use and to differentiate them.

> - XML allows me to do versioning within documents.

What kind of versioning are you referring to? Schema versioning? Data versioning?

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#42

XML is well regarded in the enterprise and languages like JAVA, C#, and VB.NET handle is spectacularly as an exchange format. I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there. I recall working with a partner who we were doing an identity federation with. Our system was using WS-Trust which is a SOAP/XML protocol. It wasn't ideal but everyone seemed to…

> I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there.

On the contrary, I think that XML's bad reputation comes from the fact that it is so incredibly verbose.

Also, the whole child/attribute dichotomy is a huge, huge mistake. I've been recently dealing with the XDG Menu Specification, and it contains a child/attribute design failure, one which would have been far less likely in a less-arcane format.

XML is not bad at making markup languages (and indeed, in those languages attributes make sense); it is poor at making data-transfer languages.

JSON has become popular because a lot of bad programmers saw nothing wrong with calling eval on untrusted input (before JSON.parse was available). It's still more verbose than a data transfer format should be, and people default to using unordered hashes instead of ordered key-value pairs, so it's not ideal.

The best human-readable data transfer format is probably canonical S-expressions; the best binary format would probably be ASN.1, were it not so incredibly arcane. As it is, maybe protobufs are a good binary compromise?

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#43

Earlier quoted context omitted.

Totally, we took this a step further and created a subversion repository where xml documents describe classes. Each method is either inline, or is described by a xml element of a particular namespace that links to a subversion id and revision. ;)

Note: I believe this is a reference to http://thedailywtf.com/articles/the-inner-json-effect

What? No! Someone stole our XDSL concept and called it JDSL. Bastards! All these hipsters taking XML ideas and rewriting them in JSON because JSON is "cool" now. sigh

(yes ;))

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#45

XML is well regarded in the enterprise and languages like JAVA, C#, and VB.NET handle is spectacularly as an exchange format. I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there. I recall working with a partner who we were doing an identity federation with. Our system was using WS-Trust which is a SOAP/XML protocol. It wasn't ideal but everyone seemed to…

What do you think JAVA stands for? It's not an abbreviation. It's the name of an island and it's just 'Java'.

It's more accurate to say that it's named for the coffee beans that come from said island.

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#46

Why would anyone choose to use XML over JSON, other than for RSS?

For one, JSON didn't exist 15 years ago. For another, JSON didn't have validation or schemas 5 years ago.

JSON was defined in April 2001, basically a subset of JavaScript specs from 1999.

So, JSON did exist 15 years ago, but not 16 years ago, although you have to go back 20 years if you want your statement to not just be about the name.

And yet ... how many of the decisions to use XML go back those 15 years? Hardly any.

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#47
post #32

Earlier quoted context omitted.

Well, XML is complicated, so it's hard to build support for, and it's verbose, so it's heavy on the wire. Frankly, I think JSON is a better format in most contexts.

The biggest problem with XML is that it's a node labeled tree that makes the schema choice between leaf node and attribute for scalar data almost arbitrary, whereas JSON is an edge labeled tree without the same choice. Most programming languages use edge labeled graphs for in memory data structures, so the semantic distance is lower with JSON.

Indeed. Even translating to Lisp, which has closer datastructures than most languages, the XML is translated to an edge-labeled tree.

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#48
This reminds me of an interesting experience I had with XML at a pervious job a few years ago.

We had bought a product from another company which was to be integrated into our own main product. Theirs was horribly ugly, looking like a cross between a 90's website and an infomercial, predominately in vivid shades of pink and purple. And it was really buggy. I soon noticed that all the content (many hundred pages with text, video and interactive content) was specified in a giant XML file and that the application itself simply interpreted this file and presented it to the user. We quickly decided that the best course of action was for me to reverse-engineer this XML file and write our own code to generate an integrated version of it, presented in a visual style more in line with the rest of our own product. This meant we could also solve some of their bugs on the way.

I still feel this was the only reasonable option and it did work out within our given time frame. However, I will never forget the horrors I saw in that one file. A few gems included:

- The file was most certainly handwritten with lots of tag mismatches and spell errors in tag names.

- One of the main sections was missing in their own standalone version because of a syntax error which caused their program to skip over the entire main branch of the syntax tree in which it occurred.

- Exercises where you had to order a list of items were defined as dragging items into hit boxes on a static bitmap image of the numbers 1-10 on a purple background. The same image was used regardless of how many items had to be ordered. The hit boxes didn't align with those numbers at all and often overlapped. In their implementation, Items were stuck right where you dropped them, rather than snapping to a fixed position by the right number.

- We wrote a few tools to identify images and videos which were either present on disk but never referenced or vice versa. This was often a case of spelling errors, slight variations in word connotation or files placed in the wrong folder. In these cases, their original program would bail out and skip that page.

- Indices of chapters were written as plain text rather than inferred. They did not match how things were laid out in the XML and where it happened to align it was sooner or later broken by sections which were commented out or failed to parse.

There were many more issues, but these give some insight into the exciting challenge of getting their data to work in a consistent and logical manner. After the XML file had been thoroughly massaged into submission and uniformity, of course.

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#49
I used to hate doing XML in Python - ElementTree was the nicest of them 10 years ago, but it still hurt.

But last year, I discovered xmltodict[0] and since then, I don't really care - it makes doing xml (both reading and writing) no more cumbersone than using dicts, while still supporting stuff like namespaces, CDATA and friends.

I still think XML is a horrible, misguided idea - from inception, but even more so in how it is used in practice - but I no longer feel any pain interfacing with it.

[0] https://github.com/martinblech/xmltodict

Re: How to Avoid Being Called a Bozo When Producing XML (2005)

#50
post #42

XML is well regarded in the enterprise and languages like JAVA, C#, and VB.NET handle is spectacularly as an exchange format. I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there. I recall working with a partner who we were doing an identity federation with. Our system was using WS-Trust which is a SOAP/XML protocol. It wasn't ideal but everyone seemed to…

> I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there. On the contrary, I think that XML's bad reputation comes from the fact that it is so incredibly verbose . Also, the whole child/attribute dichotomy is a huge, huge mistake. I've been recently dealing with the XDG Menu Specification, and it contains a child/attribute design failure, one which would ha…

> "The best human-readable data transfer format is probably canonical S-expressions"

I personally think TOML is a bit more readable...

https://github.com/toml-lang/toml

Post reply on HN