Domain-Specific Programming Language (DSL)

Jump to navigation Jump to search

A Domain-Specific Programming Language (DSL) is a programming language that is tailored to solve some domain-specific tasks.



  • 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.


  • (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



   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


  • (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.