I like to explain a DSL as being like Pig-Latin.
You can use Pig-Latin on English or French or Spanish or really many languages.
The main idea of using Pig-Latin is that you have to have a base language to use it on.
A DSL abstracts the base language for a different purpose, whether making it a bit easier to write HTML like Markdown or HAML both do or by using the base language for a specific purpose like writing tests (RSpec.)
A DSL is indeed a "mini-language" as stated below but specifically it is a "mini-language" which uses another language to write it.
Try some Pig-Latin
For words that begin with consonant sounds, all letters before the initial vowel are placed at the end of the word sequence. Then, "ay" is added, as in the following examples:
- "pig" → "igpay"
- "banana" → "ananabay"
- "trash" → "ashtray"
- "happy" → "appyhay"
- "duck" → "uckday"
- "glove" → "oveglay"
Try some Markdown
"Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). " ~ Daring Fireball
Markdown makes it quicker and easier for you to write HTML in your applications but it is actually converted to HTML when the browser reads your code.
- <h1>This is First Level Header in HTML.</h1>
- # This is a First Level Header in Markdown. (one # sign)
- <h2> This is a Second Level Header in HTML.</h2>
- ## This is Second Level Header in Markdown. (two # signs)
- <blockquote>This is a blockquote in HTML.</blockquote>
- < This is a blockquote in Markdown. (One < sign.)
My previous thoughts:
We were talking about DSLs at my study group this week and it finally locked into my head what a DSL is. I didn't realize that RSpec was basically ruby with extra functionality so RSpec is a DSL. And now reading this wiki post, that HTML is a DSL and YAML and HAML. Wow.
A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains, and lacks specialized features for a particular domain. There are a wide variety of DSLs, ranging from widely used languages for common domains, such as HTML for web pages, down to languages used by only a single piece of software.
DSLs can be further subdivided by the kind of language, and include domain-specific markup languages, domain-specific modeling languages (more generally, specification languages), and domain-specific programming languages. Special-purpose computer languages have always existed in the computer age, but the term "domain-specific language" has become more popular due to the rise of domain-specific modeling. Simpler DSLs, particularly ones used by a single application, are sometimes informally called mini-languages.