A DSL, or Domain Specific Language, is a language that has a specific purpose rather than a general purpose like C or Java. One of the most popular DSLs is SQL because it’s the standard for querying a relational database and it’s syntax is specific to activities such as sorting, filtering and displaying data.

SQL falls under the category of external DSLs which means it requires its own parser and implementation of all of the necessary components. Other examples of external DSLs are Gherkin, for writing feature files, Make Files, for building C and C++ applications and HTML, for declaring webpages).

What is a Ruby DSL?

Ruby is a powerful and expressive language that can be leveraged to create an internal DSL. Instead of requiring a full-syntax parser and an underlying implementation, metaprogramming techniques can be used to create a DSL that leverages the Ruby language.

Anyone that has used a popular Ruby framework has most likely seen a Ruby DSL. Frameworks that leverage these include:

Rake

RSpec

Active Record

Sinatra

Before RSpec came along, TestUnit was the most popular testing framework in Ruby. A test looked a lot like a typical Ruby class: