How DSLs Enable Reliable Use of LLMs in Software Development
I argue that Domain-Specific Languages make Large Language Models far more reliable by constraining the output space. While upfront specifications are often just hypotheses, DSLs provide a clear vocabulary and deterministic validators. This allows LLMs to act as effective co-designers and precise interfaces, turning natural language into valid code or configurations that can be automatically checked and repaired without human intervention.
A specification is at best a starting hypothesis: the real constraints, trade-offs, and edge cases are discovered iteratively, as we proceed with the implementation.
- codegladiator
> The advantage holds while the DSL stays small and constrained enough that a few in-context examples can convey its usage. There is also a real upfront cost in designing and maintaining the language and its semantic model. The payoff is therefore concentrated in well-factored, genuinely constrained DSLs backed by a validator.
dsl stays small is doing all the heavy lifting here
the premise is that because of these few existing dsls (like PlantUML mentioned) my "new dsl" will be equally effective. PlantUML has millions of examples in the training data, my new dsls are not (specially if its not json/yaml or just function chain based). as the number of things that can mix and match increase you are basically looking at a whole system prompt just describing the new language.
this brings us to the second part. step 2: after dsl is 'planned' (note they use the java compiler), the dsl need to have a real compiler/executor, not just a validator. because if then you are going to ask the llm to "compile the dsl to implementation" we are back to square 1.
- andy_ppp
What is the general consensus on Martin Fowler - I worked with Thought Works and they were obsessed with overcomplicating everything, but maybe that is just agency in general?
I think it goes without saying that the biggest fight we have as developers is keeping things as simple as possible when most external factors encourage complexity, especially LLMs.
- skydhash
That’s basically LISP 101. Before solving a problem, you build out the spare parts and the tooling. And then the software building feels like assembling lego blocks. Building a DSL or a good set of symbols (functions/classes/constants/enum/…) is the cornerstone of DDD.
The actual implementation details only matters at the coding stage. At the design stage, it’s better to define the glossary and its semantic.
- lelanthran
Pretty much how I use LLMs these days. Even Chatbots are able to work with a 200 line spec for the DSL.
You'd think it wouldn't because, well, no training data, but a short spec is usually enough.
- persedes
As much as I dislike them [1], DSLs are an easy way to provide domain specific backpressure to your llm which might not easily be available in your language.
1- https://mikehadlow.blogspot.com/2012/05/configuration-comple...