Jim Freeze talking about writing DSLs in ruby

Jim Freeze has an interesting post about writing DSLs in ruby. Check What is a DSL? – O’Reilly Ruby:

The third time around, after the Ruby DSL hype had been going around for a while, I decided to use Ruby. This time, I was able to create the DSL in about five minutes. It was readable, and I was able to focus on the end users frame of reference.

The moral of this story is, don’t write a mini language if you don’t have too. And, don’t settle for a simple DSL when a full featured one is needed. Consider extending a GPL into a DSL. Particularly an expressive language that is good at creating a readable DSL — like Ruby.

IMHO the key point here is that it is easier to code your domain in the simplest and expressive way (ala DDD), and later let it emerge a DSL shaped on that, rather than build a priori a monstrous DSL with a formal definition, a parser generated from a grammar, etc. And XML/XSLT don’t help either, both for readability and handling issues.

Many thanks to Lawrence Oluyede for having me signalled this.


One Response to “Jim Freeze talking about writing DSLs in ruby”

  1. riffraff Says:

    I found interesting the experience of the freebsd developers about ifconfig(8). Argument parsing is basically a minilanguage that grew wildly with time, and it reached the point when writing a YACC based parser become a suitable refactoring.

    It may be seen as a usual YAGNI experience, but I have some doubts about it: maybe using a real parser since the beginning could have saved a lot of work in maintaning an ad hoc solution for a long time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: