Why is Ruby on Rails called a domain-specific language?

Technically, ruby is not a DSL, it just lends itself to writing internal DSLs very cleanly. This link to Martin's Fowler's blog wiki should help clarify things.

Rails has been described as a DSL although I think of it more precisely as a framework that makes very good use of a few DSLs.

Edit: The intro to the public version of Martin Fowler's DSL book has a motivating example, although it is still aimed a bit more at programmers.

Edit again: The "voodoo" example can be useful if you point out that ruby allows ruby code to look like

port 2001

respond :resource=>"/hello" do  |request, response|
  response.body = "<message>hello</message>"
end

which is cleaner than calling the methods directly. Implementing a DSL can require "voodoo" like code (it is much harder creating a DSL than using one), and in general someone relatively new to coding should worry first about what the DSL does and not so much how it is implemented.

What makes ruby good at internal DSLs includes (1) use of blocks (any language with clean closures has this advantage), (2) method class that do not require parentheses, and (3) the ability to modify classes on the fly (which is what validates does). There are probably more I haven't thought of.


Ruby is a language that you can use to create a DSL. Ruby on Rails may be considered a DSL (Domain Specific Language) for creating web applications.