Topic summary

Domain-specific language

Domain-specific language

A domain-specific language (DSL) is a programming language specialized to a specific application domain. This is in contrast to a general-purpose programming language, which is broadly applicable across domains. There are a wide variety of DSLs, ranging from widely used languages, such as SQL, down to languages used by only one or a few pieces of software, such as MUSH soft code. Simpler DSLs, specifically ones used by a single application, are sometimes informally called mini-languages.

The line between general-purpose languages and domain-specific languages is not always sharp, as a language may have specialized features for a given domain, but be applicable more broadly, or conversely may in principle be capable of broad application but in practice used mainly for a specific domain. For example, Perl was originally developed as a text-processing and glue language, for the same domain as AWK and shell scripts, but was mostly used as a general-purpose programming language later on. In contrast, PostScript is a Turing-complete language, and in principle can be used for any task, but in practice is narrowly used as a page description language.

Metaprogramming can involve the creation and usage of a DSL to generate code. Some languages like Lisp allow modifying their own syntaxes. When doing so, it is common to speak of the creation of a new DSL. Operator overloading, as found in C++, can also create a new DSL.

DSLs are more often declarative than general-purpose languages. Examples: QML, SQL, XSLT, by some people CSS is considered a declarative domain-specific programming language