Menu
Martin Fowler·July 14, 2026

Leveraging DSLs and LLMs for Reliable System Design and Code Generation

This article explores how Domain-Specific Languages (DSLs) can be used in conjunction with Large Language Models (LLMs) to enhance the reliability and precision of code generation for distributed systems. By providing clear boundaries and acting as a source of truth, DSLs guide LLMs to produce exactly the intended system behavior, reducing ambiguity and improving software quality. The approach allows for iterative DSL development and natural language interaction with complex system models.

Read original on Martin Fowler

The Challenge of LLM Code Generation in System Design

While Large Language Models (LLMs) can generate code at unprecedented speeds, their output often lacks the precise intent required for complex software systems, especially in distributed environments. The inherent ambiguity of natural language can lead to misinterpretations, making the generated code unreliable or functionally incorrect. This article highlights a critical architectural concern: how to harness the power of LLMs while ensuring the integrity and accuracy of the resulting system components and behaviors.

DSLs as a "Harness" for LLMs in System Development

The core proposition is to use Domain-Specific Languages (DSLs) as a robust 'harness' for LLMs. DSLs provide clear, unambiguous boundaries and a structured vocabulary tailored to a specific problem domain. When an LLM is guided by a DSL, it operates within a well-defined context, significantly reducing the chances of generating erroneous or unintended code. This architectural pattern leverages the LLM's generative capabilities for speed, while the DSL ensures precision and adherence to system requirements. The article uses "Tickloom," a DSL for distributed system behavior, as a practical example.

💡

DSL Benefits for System Design

DSLs offer several advantages in system design: they enforce consistency, reduce cognitive load for domain experts, and provide a high-level abstraction that can be translated into various implementation details. Integrating them with LLMs creates a powerful synergy for complex system modeling and generation.

Iterative DSL Development with LLMs

The article suggests an iterative approach where LLMs can act as partners in *building* the DSL itself, not just using it. This involves defining initial DSL structures, providing examples, and using the LLM to refine the language, identify ambiguities, and even suggest extensions. This collaborative development process allows the DSL to evolve alongside the system's understanding, becoming a more accurate and comprehensive source of truth for the software system.

DSLs as the Source of Truth

In an LLM-driven development paradigm, a well-designed DSL can serve as the primary source of truth for a software system. Instead of maintaining verbose natural language specifications or complex diagrams, the executable DSL model precisely defines system behavior and interactions. This clarity reduces miscommunication between developers, stakeholders, and the LLM itself, leading to more robust and maintainable architectures, especially for distributed systems where behavior can be intricate.

LLMDSLCode GenerationSystem ModelingSoftware ArchitectureDomain-Driven DesignDistributed Systems

Comments

Loading comments...