Last night, I was working on a little demonstration project, teaching myself the intricacies of Backbone/CouchDB interaction. I wrote my first CouchDB views and figured out what they're for, which is a massive step toward world domination and all that. I was working on the retrieval layer, and thinking about the create/update features, when I said to myself, "Hey, Self, can you use that sexy new RDFa stuff to handle the create/update feature?"

I've been thinking about this because I have a different project that's very RDFa-heavy, and the details of implementation have been challenging. But no, I had to come to a different conclusion:

RDFa and Backbone.js are incompatible.

RDF is a framework for self-describing data, such that the data carries along with itself tokenized indicators for how it is to be organized, presented, and edited. The idea is simple: the browser requests a page, the server sends it all: the HTML represents the structured data, the CSS the visual depiction, and the javascript detects the RDFA (the 'A' stands for 'attributes', HTML attributes) and decorates these islands of content with controls to make the content editable and saveable back to the server.  The data itself is kept in a representative semantic form of (X)HTML trees.

Backbone, in contrast, is a software framework in which the data is represented in a tree-like structure in Javascript itself, in the models and collections. The data does not come down with the page, but is requested after the fact by Backbone.  The HTML is rendered as a side-effect (my Haskell classes are rubbing off on me): it is a representation of the data-state on the client. Backbone works hard under the covers to keep the client and server state in sync, but in all cases the HTML is just a representation of the data; it is not the data itself.  The data itself is kept in Javascript trees.

These are two completely different approaches to managing data on the client. Both are valid. And both have their uses, but for the moment they don't mesh well.

"If you have an idea and publish it on the internet, it counts as the ghost of done."

So here's my ghost:

We need a Backbone-like for RDFa. RDFa cannot easily be coerced into working with Backbone, but let's face it: there are only a few things we work with on the internet: text and inputs, and lists and trees of text and inputs.

It ought to be possible to formalize a backbone-like collection of Views, Schemas and Rules, such that the transition from presentation to revision is seamless and perhaps not even distinct, and synchronization for a range of RDFa-enabled articles, forms, fieldsets, and the like is automagical. In other works, make Models and Views "know" about their data because it's already present in the HTML, and not the other way around.  It's the transition from page-format to server-side format that's the pain point.

Hmm. This needs more thinking.