Presentation: Ruby and the Art of Domain Specific Languages
Domain Specific Languages (DSL) are a popular topic (see InfoQ's extensive coverage on DSLs) across all language communities.
In this presentation, Rich Kilmer looks at creating DSLs in Ruby. Next to the usual distinction between external DSLs (involve writing a grammar and a parser) and internal DSLs (piggyback on the host language's grammar and parser), he explains useful terminology.
Rich distinguishes betwen an implicit and explicit styles - this deals with questions of language design. An example of an explicit DSL is this:
The talk is rounded off with Rich looking at a very long list of real world DSLs he has written over many years for work. This provides valuable real life experience from designing and working with these DSLs. Lessons include how designing a DSL can help uncover holes in specs, simply because code is less forgiving than prose.
Watch Rich Kilmer's Ruby and the Art of Domain Specific Languages.
Discuss
In this presentation, Rich Kilmer looks at creating DSLs in Ruby. Next to the usual distinction between external DSLs (involve writing a grammar and a parser) and internal DSLs (piggyback on the host language's grammar and parser), he explains useful terminology.
Rich distinguishes betwen an implicit and explicit styles - this deals with questions of language design. An example of an explicit DSL is this:
when_shopping do |store|An example for an implicit DSL is this:
store.buy :popcorn
store.buy :soda, @soda_amount
end
when_shopping {
buy :popcorn
buy :soda
}
Both approaches have benefits and problems. One issue of explicit DSLs is the added token noise, eg. the formal block argument definition. As Rich explains, this noise can look confusing when domain experts are supposed to read and check the code written in the DSL. An implicit DSL looks cleaner - yet it has the problem that it's possible to have scoping problems or that it's unclear where the called functions or methods actually come from. Rich goes into more detail about the trade-offs of either approach and when to use which. The talk is rounded off with Rich looking at a very long list of real world DSLs he has written over many years for work. This provides valuable real life experience from designing and working with these DSLs. Lessons include how designing a DSL can help uncover holes in specs, simply because code is less forgiving than prose.
Watch Rich Kilmer's Ruby and the Art of Domain Specific Languages.
Community comments
Educational Content
Managing Build Jobs for Continuous Delivery
Martin Peston May 24, 2013
Clojure in the Field
Stuart Halloway May 23, 2013
Tuning the Size of Your Thread Pool
Kirk Pepperdine May 23, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think