Home > Positioning > Subjects > Domain-Specific Languages (DSL)
Domain-Specific Languages (DSL)
A domain-specific language (DSL) is a language designed for a particular problem area rather than for general-purpose use. Where a general-purpose language like Python or Java can address a wide range of computational tasks, a DSL restricts its scope to a specific domain and gains expressiveness within that domain in return. SQL handles relational databases. CSS governs visual layout. Regular expressions match patterns. Each has its own grammar, its own operators, and its own way of saying what matters within the domain it serves.
Topics
- Classification axes — the ways DSLs can be classified: internal vs external, declarative vs imperative, notational vs executable, and more.
- Internal DSLs — DSLs embedded in a host language, from Ruby’s expressiveness to Haskell’s monadic embedding.
- External DSLs — DSLs with their own grammar and parser: SQL, regular expressions, Make, and the implementation pipeline behind them.
- Language workbenches — integrated environments for defining DSLs, from JetBrains MPS to Eclipse Xtext.
- Design considerations — when to build a DSL, the costs and benefits, common pitfalls, and patterns for evolution.
- History — the lineage from 1950s proto-DSLs through the Unix small-languages tradition, the internal DSL renaissance, and the language workbench era.
- The pattern beyond software — purpose-built vocabularies in mathematics, science, music, and philosophy, and the deeper pattern they share.
Examples
A non-exhaustive selection across domains:
- SQL — relational database querying
- Regular expressions — text pattern matching
- CSS — visual styling and layout
- HTML — document structure and hypertext
- Make — build dependency management
- LaTeX — typesetting and document preparation
- APL — array-oriented mathematical notation
- GraphQL — API querying
- Terraform HCL — infrastructure as code
- Musical notation — encoding performance (pitch, rhythm, dynamics)
- Chemical formulas — molecular structure (SMILES, InChI, IUPAC nomenclature)
- Mathematical notation — symbolic reasoning and calculation
Sources
- Fowler, M. (2010). Domain-Specific Languages. Addison-Wesley.
- Mernik, M., Heering, J., & Sloane, A. M. (2005). When and how to develop domain-specific languages. ACM Computing Surveys, 37(4), 316–344.
- Iverson, K. E. (1980). Notation as a tool of thought. Communications of the ACM, 23(8), 444–465.
See also: Category Theory · XPath