Ruby DSL’s vs YAML vs XML

Monday, May 14th, 2007

I am using Ruby based DSL’s for a number of tasks in my current project. But one day it struck me - am I using the right tool for the job, could there be a better, more simple solution?

Some DSL’s I use are simply declarative and look something like this:

I find that quite readable, but it requires me to maintain code that handle the DSL. So I figured, what if I used YAML? It is simple, and using it would mean less code to maintain.

After doing some experimenting, this is what I came up with:

In my opinion, the YAML is not as readable as the Ruby DSL. I also find it more error prone as those dashes are sort of tricky.

XML?

With the correct schema, errors can be avoided, but it is just too much text in there, it gets heavy and verbose.

The verdict was to stay with the Ruby DSL’s - their readability and flexibility are well worth the effort of maintaining a separate parser - which is quite short really.

Any Damn Fool

Wednesday, April 11th, 2007

Tim Bray is my hero of the day. So many other people would defend their brainchild, especially a world conquering one, in any situation but Tim clearly stands above such behavior.

Any Damn Fool: “… we designed XML as a document format. When the world gleefully seized upon it as a data-packaging/RPC tool, that was OK, but I doubt you could get any of XML’s original designers to disagree with the statement that JSON, for example, has all sorts of advantages for wrapping up short-lived strongly-typed data.”

(Via ongoing.)