Irakli Betchvaia's DSL method lifted first-compile rates from 25 to 87.5 percent
In an InfoQ article published today, Irakli Betchvaia introduces Typed Domain Grounding, which embeds a home-grown DSL inside a mainstream typed language so the compiler catches model hallucinations that a lenient renderer would let through.
/filters:no_upscale()/articles/next-dsl-author-language-model/en/resources/1figure-1-two-spaces-of-grounding-1789050057204.jpg)
Image: Irakli Betchvaia, via InfoQ
Why it mattersTeams that give coding agents a custom notation get invented syntax with confident tone; putting the DSL inside Kotlin or TypeScript turns those inventions into compile errors the agent can see and repair.
In an InfoQ article published on 16 September, Irakli Betchvaia introduces Typed Domain Grounding, a design pattern for domain-specific languages that are read and written by language models. The claim is that a home-grown DSL, embedded inside a mainstream typed host language, turns model hallucinations that a lenient renderer would silently accept into compile errors the model can see and fix. Betchvaia supports it with a fifty-task benchmark on kUML, a Kotlin-embedded modeling language for UML, SysML v2, and C4 diagrams.
Where retrieval falls short
Betchvaia argues that retrieval-augmented generation supplies the facts in a response but does nothing for the notation used to express it. A model can have correct facts in context and still emit a DSL statement with invented keywords, guessed parameter names, and constructs that were never in the specification. He calls this a training-corpus-frequency problem: mainstream languages appear in millions of public files, and a freshly designed external DSL appears in none. The usual fixes of more prompting, longer context, and better retrieval do not address the gap.
The alternative rule, in Betchvaia's own sentence: never invent syntax a model has never seen. Embed the domain in a language it already writes fluently, and let the compiler be the judge.
The five design commitments
The article describes five parts. The DSL is embedded rather than external, so it inherits highlighting, completion, refactoring, and reviewer-familiar diffs from the host toolchain from the start. The host language is chosen by how much training data exists for it, which Betchvaia says points to Kotlin, TypeScript, or Python for most domains. The API is shaped so that domain errors appear as type errors, using named parameters, enums instead of strings, sealed hierarchies, and receiver-scoped builders. A generate-compile-repair loop feeds the compiler diagnostic back to the model as a targeted repair prompt, bounded at three attempts in the kUML setup. An on-demand teaching channel, exposed as a tool the model can query mid-generation, returns a small set of known-good compiling examples for the exact construct the model needs.
The measured effect
Betchvaia reports that on a fifty-task benchmark with Claude Sonnet 5, kUML reached higher Structural Fidelity and a lower hallucination rate than two lenient external DSLs, despite a lower first-try compile rate. He says the same pattern held for GPT-4o, and adds that it does not hold for every model tested, so a strict compiler that rejects errors can lead to more reliable output than a forgiving one but is not guaranteed to. The most concrete number in the article is on the teaching channel: for kUML, exposing a curated examples tool raised the first-compile rate for SysML v2 diagrams from 25 percent to 87.5 percent.
The trade-offs are stated plainly. TDG fixes syntax errors; errors of understanding remain. It gives up notational freedom, and it commits the project to a host language. Betchvaia frames it as a default consideration for new DSLs, and does not ask teams to rewrite ones that already work.
For a team giving a coding agent its own notation, the argument is that the compiler is a cheaper and more reliable reviewer than a prompt, and that the fix belongs in the language design itself.
Source
Your Next DSL Author Is a Language Model, by Irakli Betchvaia on InfoQ.
This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.
Get AI News in your inbox
New developer tools, model and agent releases, and how teams are actually using them to release software. Short, and only when there is something worth reading.


