Writing Domain Specific Languages (DSLs) with Ruby

August 03, 2009

A lot of people say that Ruby is a great languages for writing Domain Specific Languages (DSLs). A DSL is a highly abstracted programming language that gives you a natural and intuitive way to deal with a specific logical domain. They can serve as easy flexible APIs for programmers or enable clients to have control over the way a system deals with their business logic. There are lots of examples of DSLs in the Ruby world. Capistrano, RSpec, Thinking Sphinx, Rails’ Routing, just to name a few.

In this post I’ll look at some of the most common ways to create a DSL in Ruby.

A DSL for Defending Medieval Castles

A new client, Medieval Guards, Inc. specializes in guarding medieval castles and fighting off Barbarian attackers.