[Avg. reading time: 6 minutes]
DSL
Domain-specific languages (DSLs) are super interesting because they’re tailor-made for specific tasks or industries, like SQL for databases or HTML for web pages.
DSLs can reduce code complexity and increase productivity for specific tasks.
A Domain Specific Language is a programming language with a higher level of abstraction optimized for a specific class of problems. (a.k.a) Specialized to a particular application domain.
Why DSL?
- Express intent directly instead of implementation details
- Reduce code size and complexity for domain-heavy tasks
- Enable non-traditional programmers to work productively
- Standardize how a domain is modeled and reasoned about
Common and Widely Used DSLs
- HTML – Structure and semantics of web documents
- CSS – Presentation and layout rules for the web
- SQL – Declarative querying and data manipulation
- Markdown – Lightweight documentation and content authoring
- Mermaid – Diagramming using text-based syntax
- Sed – Stream-based text transformation
- XML – Structured data representation and interchange
- UML – Visual modeling of system design
- Terraform – Declarative infrastructure and cloud resource management
https://www.chatdb.ai/tools/markdown-formatter
DSL Types
Declarative DSL
- SQL
- HTML
- CSS
- Terraform
- Mermaid
- UML
- XML
- YAML
Use when
- Desired state matters more than execution steps
- Systems should decide how to reach the goal
- Idempotency is important
Imperative DSLs
describe how to do things step by step.
- Sed
- Awk
- Bash
- Makefiles
- Jenkinsfile
Use when
- Order of execution matters
- You need fine-grained control
- Declarative abstractions leak
Configuration DSLs
- Application.yml
- Github Actions
- Docker Compose
Use when
- These are programming languages
- They have control flow, dependency graphs, and failure modes
- Treat them with the same discipline as code