
Share
Compilers thrive on clear-cut rules, but large language models struggle with semantic closure, unable to internally verify their outputs due to their stochastic nature and reliance on vast, ambiguous data sets.
When it comes to software development, the difference between compilers and large language models (LLMs) goes beyond just determinism versus stochasticity. It's about a fundamental property known as semantic closure-the ability of a system to define, interpret, and verify its own outputs internally.
Traditionally, compilers have been deterministic systems that follow strict rules for parsing and validating code. They can definitively tell you when something is wrong because they operate within a well-defined language specification. On the other hand, LLMs are probabilistic models that generate outputs based on learned patterns from vast datasets. They lack the internal mechanisms to verify their own correctness.
A compiler achieves semantic closure through the following properties:
For example, if you feed a C compiler a file with a type error, it will stop, point to the specific line, and explain the mismatch. It knows the program is wrong because it has a formal definition of what "correct" means in the context of the C language.

LLMs, by contrast, do not achieve semantic closure:
Consider asking an LLM to write a function that reverses a linked list. The model might produce something that compiles, but it could silently corrupt memory for lists longer than 255 elements. The model has no way to distinguish between correct and incorrect outputs because it lacks the formal structure to do so.
For practitioners, understanding semantic closure is crucial because it highlights the limitations of LLMs in critical applications. While LLMs are incredibly powerful for generating code and text, they cannot replace the deterministic guarantees provided by compilers. This is particularly important in domains where correctness is paramount, such as safety-critical systems or financial software.
The key takeaway is that semantic closure is a systems property that describes whether a system can internally define, interpret, and verify its own outputs. Compilers achieve this through formal language specifications and deterministic processes, while LLMs rely on probabilistic models and lack the internal mechanisms to ensure correctness. As we continue to integrate AI into our development workflows, it's essential to recognize these differences and use the right tools for the job.
Tags
Original Sources
↗ https://sderosiaux.substack.com/p/semantic-closure-why-compilers-know?utm_source=tldrai
About the author
Kai built ML infrastructure at a Bay Area startup before developing an obsession with transformer architectures and inference optimisation that eventually pulled him out of product work entirely. A stint at a compute research lab sharpened his instinct for what actually matters in a model release versus what is marketing. He writes from the inside — from the perspective of someone who has debugged the systems he is describing at three in the morning. He is allergic to hype and instinctively drawn to the unglamorous plumbing questions that everyone else skips over.
More from The Engineer →This Week's Edition
19 February 2026
133 articles
Related Articles
Related Articles
More Stories