The Wikipedia article for domain-specific languages seems only to refer to actual languages.

However, I've heard the term "DSL" used to refer to unique-looking coding paradigms encouraged by libraries in "standard" languages.

From Ruby on Rails, for example (from here):

create_table :posts do |t|
  t.string :name
  t.string :title
  t.text :content


That is Ruby code. It's not it's own language, but it's a unique coding style encouraged by a library in order to make coding in a specific domain more readable.

Is there a separate term for this?

  • What's a "standard" programming language? Apr 19, 2011 at 12:08
  • @Larry Coleman, a "standard" or "general purpose" language is one that is designed for many different applications. Examples are C, C++, C#, Java, Erlang, Ruby, Python, Perl, Lisp, Smalltalk, and others like them. This is in contrast to domain specific languages that are designed for one purpose. Examples of that type of language are: SQL, XML, HTML, CSS, YAML, and others like those. The last category of languages are "regular" languages such as Regular Expressions, CSV files, etc. Apr 19, 2011 at 12:15
  • @Berin: That is the generally accepted definition, but I'm not sure if that's what the OP meant. Substituting "general purpose language" for "standard language" in the second paragraph of the question doesn't seem to work. Apr 19, 2011 at 12:18
  • The OP was citing the embedded DSL for database migrations that was implemented in the standard language Ruby. The DSL is 100% Ruby code, just formatted to be a bit more declarative than usual. It's the same approach used by the Ruby build tool Rake. In this case Ruby is the standard language, and the migrations code is the DSL. Similar parallels work with attribute languages and C#, such as NUnit code. Also, the Hamcrest Assertion library is an example of an embedded DSL written in 100% pure Java. Unless I'm reading something wrong. Apr 19, 2011 at 12:22
  • @Berin: I was just nitpicking about the quotes around the word "standard." I'll stop now. Apr 19, 2011 at 12:43

5 Answers 5


I've heard such a thing referred to as an "internal DSL" or an "embedded DSL".


Just because Wikipedia doesn't mention it doesn't mean it doesn't exist :) I generally use the term DSL for embedded languages within a particular language (and for me, this includes printf and regexes). I like the term "little language" for constrained languages that don't have the full power of a programming language behind it, but may still require tokenization and parsing. But domain-specific language is the right term of art, regardless of whether your language is built using the features of your language or if you're building a completely new language.

I'd use the term DSL in the broader sense as well, for full-on programming languages targeting problems in a particular domain, but I've mostly built DSLs with the help of existing languages, namely Boo and Ruby. If your language supports metaprogramming, or functional abstractions, it's usually possible without much effort to build a DSL in or around the language. (In Boo, I usually build a DSL as an extension to the language using features of the compiler pipeline and the semantic macro syntax).

If you have less control over the syntax tree or the method call syntax is less flexible, you can use method chaining to create a fluent interface, which is a subset of what we think of as a DSL.

DSLs are well supported in Lisp-inspired languages, where you're essentially building a DSL anytime you write code.

As an aside, Donald Knuth also used the term literate programming for a style of programming that's self-documenting because the code serves as a readable document.

  • Does this answer the question? Apr 19, 2011 at 9:25
  • My answer is that DSL is the correct term in general, and there's not a special term for one that you build using the features of an existing language.
    – JasonTrue
    Apr 19, 2011 at 14:37

They call those "fluent APIs" or a fluent interface.

Most of the examples are focused on "method chaining", but anything that makes the code look more domain-specific is a fluent api.



In 1977, Nick Lawrence coined the term "category language" for this kind of thing. He presented a paper at a 1977 simulation conference, entitled "Simulation Category Languages". These were DSLs embedded in a general-purpose simulation language, to make certain kinds of simulations a lot easier to set up.

At the time, Nick was TI's resident discrete-event simulation guru. He was at UT Austin for a little while, teaching a seminar on discrete-event simulation.


Apart from the internal or embedded DSL name mentioned, these types of things are also sometimes related to the concept of Convention over Configuration where defining some things in a specific manner (or leaving them out entirely) is interpreted in some pre-defined manner (such as the Ruby on Rails example you give, where defining these fields signals something about how they should end up in other layers of the final running system).

  • 1
    As powerful as convention over configuration is, that doesn't address the OP's question. The syntax used in the OP's example creates a structure that is interpreted and translated into the vendor specific SQL needed to create or drop the tables. This is how many DSLs work. The fact that the framework knows how to make the conversion or find the migrations to apply is not relevant to the question. Apr 19, 2011 at 11:39
  • @Berin After reading the question again, I'm actually not sure what exactly the OP wants to know. He asks about DSLs, but the example shows both domain-specific notation and convention over configuration at work. His final comment doesn't clarify this either. I mentioned convention over configuration to make sure he doesn't come away from this discussion thinking they are the same thing (or for that matter, even related). But perhaps I am confusing him even more!
    – Deckard
    Apr 19, 2011 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.