Fowlers Introduction to Domain Specific Languages Talk

Martin Fowler gives a great talk about the style of domain specific languages, and clearly covers all the main points about the advantages and disadvantages of those styles. This guy is always worth watching, he's very good at summarizing all the sides of an issue in a very unbiased and informative manner. He doesn't specifically mention Smalltalk, but every time he says Lisp, you can just pretend he said Smalltalk, it all applies.

Here's the Smalltalk version of his sample code, in a Smalltalk DSL for comparison.

(Mapping for: #SVCL type: ServiceCall)
    extract: 4 to: 18 for: 'customer_name';
    extract: 19 to: 23 for: 'customer_id';
    extract: 24 to: 27 for: 'call_type_code';
    extract: 4 to: 18 for: 'date_of_call_string'.

(Mapping for: #USAGE type: Usage)
    extract: 9 to: 22 for: 'customer_name';
    extract: 4 to: 8 for: 'customer_ID';
    extract: 30 to: 30 for: 'cycle';
    extract: 31 to: 36 for: 'read_date'.

Simple, clean, no XML necessary, just objects and messages!

Comments (automatically disabled after 1 year)

InchingForward 6440 days ago

It'd be interesting to see the example he uses demonstrated in a Smalltalk environment.

Ramon Leon 6440 days ago

Good idea, done!

brett 6440 days ago

Do you have a link to the article?

Ramon Leon 6440 days ago

It's in the article, but you're the second to ask, so I'll make it more obvious.

diprey 6440 days ago

You don't need to be teasing people. Now, can you do it once again, in XML? Seriously though, isn't it preaching to the choir?

Ramon Leon 6440 days ago

Actually, no, it's not, since I'm hoping to draw both .Net and Ruby folk to the site to see how they compare to Smalltalk. This stuff might be old hat to Smalltalkers, but this kind of code is shocking to those from mainstream languages(though this example is too simple to truly benefit from Smalltalk), and I figure interest in Seaside will get me read by many who don't know anything about Smalltalk.

Anxious Bystander 6426 days ago

There is an interesting specific advantage of Smalltalk over Ruby here. Smalltalk can use cascaded messages (with ";") to do a natural nesting. Ruby does not have this, so has to use a block. The disadvantage of the block is that you either have to either (a) pass in an (explicit) parameter to act as (the explicit) receiver of the nested messages, or (b) use Ruby's instance_eval, which has unpleasant side-effects in some cases.

Does your ST need parenths around the first lines?

Ramon Leon 6425 days ago

Yea, the cascade operator is one of my favorites. Excellent catch, in fact it should required parens. Fixed.

[...] Some time back I read a post by Ramon Leon on domain-specific languages (DSLs), and how Smalltalk fit into that picture. He linked to an online video of a presentation by Martin Fowler, talking about this. It was very interesting. Ramon continued talking about DSLs in subsequent posts. Each time clarifying it in my mind. Over time I’ve come to realize this is the answer to why I’ve been so interested in these languages. [...] ]]

about me|good books|popular posts|atom|rss