Before the compiler

Domain-Specific Languages

When a new language is cheaper than a library, when it is much more expensive, and what the tooling bill actually looks like once people depend on it.

Domain-Specific Languages

A language restricted to one problem domain, which is what lets it say more with less and refuse to express things the domain considers nonsense. The restriction is the feature; every DSL that grows out of it becomes a general-purpose language with worse tools.

Q · What makes something a domain-specific language rather than just a library with a lot of functions?
Internal versus External DSLs

An internal DSL is written in the host language and inherits its entire toolchain for free. An external one has its own syntax and its own parser, and must build every tool from scratch. The choice is almost entirely about who pays for the tooling.

Q · Should my domain language be embedded in the host language or have its own syntax?
Should I Build a DSL?

Almost always no. Four questions decide it — is the domain stable, do the readers genuinely need non-host syntax, is the tooling budgeted, and could a library do it — and a yes needs all four. This lesson is the decision, stated as a decision.

Q · We keep saying this would be cleaner as a small language. Should we actually build one?
Implementing a DSL

Five ways to make a domain language actually run: interpret the tree, compile to the host language, compile to bytecode, generate code at build time, or embed it as schema-validated data. They differ in performance, in debuggability and in who sees the error.

Q · I have a grammar and an AST for my domain language. What do I do with it?
Configuration Languages

JSON, TOML, YAML, HCL, Jsonnet, Starlark, CUE, Dhall — a ladder from pure data to real computation. Every rung was reached by a format that started as data and was asked for one more feature, and the two that stopped deliberately are the interesting ones.

Q · Which configuration format should I use, and why do they all seem to turn into programming languages?
The Tooling Cost of a DSL

The parser is a weekend. What people expect the moment they depend on your language — positioned diagnostics, error recovery, a formatter, editor support, a debugging story, documentation, versioning and a migration path — is the project, and it never finishes.

Q · We have a working parser and interpreter. Why is nobody using our language?