Lably
Skip to content

Domain-specific language

Programming language specialized to a specific application domain

  • 13 min read
  • 6 chapters

Related on Lably

Through SQL, Syntax and CSS

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

Use

The design and use of appropriate DSLs is a key part of domain engineering, by using a language suitable to the domain at hand – this may consist of using an existing DSL or GPL, or developing a new DSL. Language-oriented programming considers the creation of special-purpose languages for expressing problems as standard part of the problem-solving process. Creating a domain-specific language (with software to support it), rather than reusing an existing language, can be worthwhile if the language allows a specific type of problem or solution to be expressed more clearly than an existing language would allow and the type of problem in question reappears sufficiently often. Pragmatically, a DSL may be specialized to a specific problem domain, a specific problem representation technique, a specific solution technique, or other aspects of a domain.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Computing and communication