Some Trees Are Better Than Others

Don Box's Spoutlet

Syndication

First, go read Doug Crockford's response to Dave Megginson's ode to S expressions.

I was shaking my head furiously (up and down) until I got to the end of Crockford's piece:

I think that Megginson demonstrated that it is hard to think about structure in XML. I hope I have demonstrated that it is easier to think about structure in JSON.

On this one, I think it depends on how you define “hard.“

Defining structure in most programming languages is much harder than doing it XML, as it's so easy to let interpretation/behavior leak into the representation/structure.  You can do it with discipline, but the flesh is weak here for most of us.

Defining structure in XML is very doable, however, it does cause you to do some pretty unnatural things.

I find I can define structure much more efficiently against JSON than I can XML.

JSON has actually eclipsed S-expressions for me as the most obvious way to structure data.  JSON effectively gives into the lure of alists and commits to them in a pretty obvious way.

Also, in both JSON and S expressions, the concrete syntax is so trivial (and orthogonal to the model) that it doesn't really get in my way.

I can't say the same for XML. Rather, I get into problems around attribute/element non-composability, atomic data typing, weird limitations on string literals (e.g., legal Unicode characters that cannot appear in values), and occasionaly the verbosity (I'm pretty immune to this but when I show XML values to colleages they run screaming).

None of these problems make defining structure in XML “hard,“ but again, they illustrate how XML is rarely the shortest path from my brain to actual data.

Now, whether any of this matters, I'll defer to Dare :-)


Posted Jan 27 2007, 01:33 PM by don-box

Comments

Julian Reschke wrote re: Some Trees Are Better Than Others
on 01-28-2007 3:28 AM
Well, one thing that Doug is missing that David's example allows not only storing given names and surnames, but also keeping their order. So, document order can give you additional information that's not immediately available in JSON.
Al wrote re: Some Trees Are Better Than Others
on 01-29-2007 8:34 AM
<a bit off-topic>

"I was shaking my head furiously (up and down) until I got..."

You wouldn't need to qualify the direction if you said that you were nodding your head furiously.

It is a little strange that shaking implies horizontal movement, and for that matter, why does horizontal movement imply disagreement? Methinks we are strange little species of water apes.
landon dyer wrote re: Some Trees Are Better Than Others
on 01-29-2007 7:18 PM
I was at a start-up which had a JSON-like architecture for RPC and storage in a number of environments, including C++, Java and Visual Basic. (The startup was Wayfarer Communications, and no, you've probably never heard of them).

Nearly a decade after Wayfarer folded, a number of the principles of the company tell me they are still using the techniques we developed there. A couple of them have done reimplementations. Efficient, rich and direct data structures that you don't *need* to get away from when you do things like messaging, database access, configuration files, and simple in-memory "stuff" are terribly, terribly addictive.

It's nice to see this stuff being reinvented :-)
Henk de Koning wrote re: Some Trees Are Better Than Others
on 01-30-2007 1:00 AM
So, who cares ? As long as it's standard. And here is where life sucks. I hate XML as much as the next guy, but at least it was something most people conformed to.

Now all we need to do is wait for the same myriad of serialization, specification and query standards to arrive in JSON world.

Chaos complete. Nothing new though.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?