Domain-Specific Programming Language (DSL)
A Domain-Specific Programming Language (DSL) is a programming language that is tailored to solve some domain-specific tasks.
- Context:
- It can range from being an Imperative DSL to being a Declarative DSL.
- It can range from being an External Domain-Specific Language to being an Internal Domain-Specific Language (Fowler, 2010).
- …
- Example(s):
- Legal-Domain DSLs, such as:
- Ergo DSL: A legal-domain DSL designed for automating contract clauses and supporting blockchain integration.
- LegalRuleML: A DSL for representing legal rules and policies in a machine-readable format.
- Akoma Ntoso: A DSL for parliamentary and legislative document structuring.
- Healthcare-Domain DSLs, such as:
- FHIRPath: A DSL for querying and manipulating healthcare data using FHIR standards.
- CQL (Clinical Quality Language): A DSL for expressing clinical decision support rules and quality measure logic.
- Software Engineering DSLs, such as:
- Gradle DSL: An internal DSL for automating project builds within the software development domain.
- Verilog: A DSL used for designing and verifying electronic systems.
- CML (Common Modeling Language): A formal specification language used for contract-based modeling in software systems.
- Data Management DSLs, such as:
- SQL Language: A declarative DSL for managing and querying relational databases.
- Regular Expression Language: A DSL for defining text patterns in strings.
- XPath: A DSL for navigating and selecting parts of XML documents.
- Statistics Programming Languages, such as:
- R Language: A statistical programming language that serves as a DSL for data analysis.
- SAS Language: A DSL for statistical analysis.
- Scientific Computing DSLs, such as:
- MatLab Language: A general-purpose numerical computing language often used as a DSL for scientific research and engineering.
- Scala-based DSLs, such as:
- Axle DSL: A Scala-based DSL used for defining mathematical and scientific models.
- System Configuration DSLs, such as:
- HashiCorp Configuration Language (HCL): A DSL for defining infrastructure as code.
- Workflow DSLs, such as:
- BPMN: A DSL for modeling business workflows.
- HTML: A DSL used for structuring content on the web.
- VHDL: A hardware description language for defining electronic circuits.
- …
- Legal-Domain DSLs, such as:
- Counter-Example(s):
- See: Embedded Domain Specific Language, Configuration File.
References
2023
- chat
- Q: what is a DSL? what different kinds are there? Provide some examples.
- A: A DSL (Domain-Specific Language) is a programming language that is designed for a specific domain or problem. Unlike general-purpose programming languages, DSLs are specialized and often easier to use for the particular problem domain they are designed for. There are different kinds of DSLs, including the following:
- External DSLs: External DSLs are programming languages that are independent of any other programming language or system. They have their own syntax and grammar, and their own interpreter or compiler. Examples of external DSLs include SQL (Structured Query Language) for database management, HTML (Hypertext Markup Language) for web development, and CSS (Cascading Style Sheets) for styling web pages.
- Internal DSLs: Internal DSLs are programming languages that are embedded within a general-purpose programming language. They often use the syntax and grammar of the host language, which makes them easier to learn and use. Examples of internal DSLs include RSpec, a Ruby-based DSL for writing tests, and Gradle, a Groovy-based DSL for build automation.
- Language workbenches: Language workbenches are tools that allow developers to create their own DSLs. These tools provide a framework for defining the syntax, semantics, and other aspects of the DSL. Examples of language workbenches include JetBrains MPS (Meta Programming System) and Xtext.
- Here are some examples of DSLs in various domains:
- Regular expressions: Regular expressions are a DSL for pattern matching in strings.
- Makefile: Makefile is a DSL for defining build rules and dependencies.
- Robot Framework: Robot Framework is a DSL for writing automated tests for software systems.
- LaTeX: LaTeX is a DSL for typesetting scientific and technical documents.
- SQL: SQL is a DSL for managing relational databases.
2014
- (Odersky & Rompf, 2014) ⇒ Martin Odersky, and Tiark Rompf. (2014). “Unifying Functional and Object-oriented Programming with Scala.” In: Communications of the ACM Journal, 57(4).In: Communications of the ACM Journal, 57(4). doi:10.1145/2591013
- QUOTE: The focus on objects and modularity makes Scala a library-centric language; since everything is an object, everything is a library module. Consequently, Scala makes it easy for programmers to define high-level and efficient libraries and frameworks — important for scaling programs from small scripts to large software systems. Its syntactic flexibility, paired with an expressive type system, makes Scala a popular choice for embedding domain-specific languages (DSLs). The main language constructs for component composition are based on traits that can contain other types, including abstract ones, as members. …
Lightweight modular staging (LMS)20 and Delite4,9 are a set of techniques and frameworks that enable embedded DSLs and "active" libraries that generate code from high-level Scala expressions at runtime, even for heterogeneous low-level target languages (such as C, CUDA, and OpenCL). DSLs developed through Delite have been shown to perform competitively with hand-optimized C code. For graph processing, the Opti-Graph DSL23 (embedded in Scala) performs on par with the standalone language Green Marl. Many Scala features are crucial for LMS and Delite to implement compiler optimizations in a modular and extensible way.21
- QUOTE: The focus on objects and modularity makes Scala a library-centric language; since everything is an object, everything is a library module. Consequently, Scala makes it easy for programmers to define high-level and efficient libraries and frameworks — important for scaling programs from small scripts to large software systems. Its syntactic flexibility, paired with an expressive type system, makes Scala a popular choice for embedding domain-specific languages (DSLs). The main language constructs for component composition are based on traits that can contain other types, including abstract ones, as members. …
2013
- (Wikipedia, 2012) ⇒ http://en.wikipedia.org/wiki/Domain-specific_language
- QUOTE: A domain-specific language (DSL) is a type of programming language or specification language in software development and domain engineering dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique.
The concept isn't new. Special-purpose programming languages and all kinds of modeling/specification languages have always existed in the computer age. But the term has become more popular due to the rise of domain-specific modeling.
Examples of domain-specific languages include HTML, Logo for pencil-like drawing, Verilog and VHDL hardware description languages, Mata for matrix programming, Mathematica and Maxima for symbolic mathematics, spreadsheet formulas and macros, SQL for relational database queries, YACC grammars for creating parsers, regular expressions for specifying lexers, the Generic Eclipse Modeling System for creating diagramming languages, Csound for sound and music synthesis, and the input languages of GraphViz and GrGen, software packages used for graph layout and graph rewriting.
- The opposite is:
- a general-purpose programming language, such as C, Java or Python,
- or a general-purpose modeling language such as the Unified Modeling Language (UML).
- Creating a domain-specific language (with software to support it) can be worthwhile if the language allows a particular 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. Language-Oriented Programming considers the creation of special-purpose languages for expressing problems a standard part of the problem solving process.
- QUOTE: A domain-specific language (DSL) is a type of programming language or specification language in software development and domain engineering dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique.
2012
- (Brambilla et al., 2012) ⇒ Marco Brambilla, Jordi Cabot, and Manuel Wimmer. (2012). “Model-Driven Software Engineering in Practice." Morgan & Claypool Publishers. ISBN:1608458822, 9781608458820 doi:10.2200/S00441ED1V01Y201208SWE001
- QUOTE:
6.4 UML Extensibility: The MiddleWay Between GPL and DSL 6.5 Overview on DSLs (Domain Specific Languages) 6.5.1 Principles of DSLs 6.5.2 Some Examples of DSLs
2010
- (Fowler, 2010) ⇒ Martin Fowler. (2010). “Domain-specific languages." Pearson Education.
- QUOTE: DSLs come in two main forms: external and internal. An external DSL is a language that's parsed independently of the host general purpose language: good examples include regular expressions and CSS. External DSLs have a strong tradition in the Unix community. Internal DSLs are a particular form of API in a host general purpose language, often referred to as a fluent interface. The way mocking libraries, such as JMock, define expectations for tests are good examples of this, as are many of the mechanisms used by Ruby on Rails. Internal DSLs also have a long tradition of usage, particularly in the Lisp community.