# DSLs Enable Reliable Use of LLMs

Domain-Specific Languages enhance the reliability of large language model outputs.

- **Source:** [Martin Fowler](https://martinfowler.com)
- **Published:** 2026-07-14
- **Topic:** [Data & AI](https://brifing.si/c/data-ai)
- **Original article:** <https://martinfowler.com/articles/llm-and-dsls.html>
- **On Brifing:** https://brifing.si/s/dd86bf09-216a-43bd-b85f-49cb8d387b01

## The Power and Limits of LLMs

Large language models can generate code and systems from high-level natural language descriptions. However, the limits of upfront specifications and the need to discover design during implementation pose significant challenges, necessitating an iterative approach.

## Limits of Upfront Specification

Designing large systems involves numerous small decisions that cannot all be known in advance. Specifications are starting hypotheses; real constraints and details emerge during implementation, requiring continuous revision.

## Design Discovery Through Implementation

Code review doesn't deeply engage with design decisions, whereas writing code forces concrete choices. The programming language and paradigm used significantly influence how the design unfolds.

## Two Roles of LLMs

LLMs play two key roles: as brainstorming partners during design and vocabulary shaping, and later as natural language interfaces. This aligns well with Domain-Driven Design principles.

## Domain-Specific Languages (DSLs)

DSLs offer constrained syntax for specific domains. Examples like PlantUML, SQL, and Kubernetes YAML can be generated accurately by LLMs, enhancing reliability by reducing variability.

## DSL and LLM Synergy

DSLs enable LLMs to produce correct syntax with few contextual examples. Unlike general-purpose languages, DSLs minimize variation, ensuring consistent outputs. They often come with built-in validators.

## Autonomous Agents and DSLs

For autonomous LLMs, DSLs provide an added advantage: validators. DSLs typically include parsers, JSON schemas, or compilers, allowing automatic validation and correction of generated code.

## Cost and Benefit of DSLs

Designing and maintaining DSLs incurs upfront costs, but well-structured, constrained DSLs justify this by enhancing LLM reliability, especially when backed by validators.

## Example: Diagram Generation

LLMs simplify creating custom tools. For instance, UML diagrams for distributed systems courses can be auto-generated. DSLs ensure high accuracy in these outputs.

## The Future of DSLs

It remains to be seen how smaller, constrained models perform with novel DSLs. DSLs will play a key role in ensuring reliable and consistent LLM outputs in software development.

## Advantages of LLM-DSL Integration

Combining LLMs and DSLs boosts efficiency in software development. DSLs ensure output accuracy, while LLMs simplify DSL usage, creating a powerful synergy.

## Conclusion: Reliable LLM Use

DSLs revolutionize software development by enabling reliable and consistent LLM outputs. This approach holds great potential, especially in designing complex systems.

## Sources covering this story

- https://martinfowler.com/articles/llm-and-dsls.html — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
