April 21, 2026
Typecast Wars: Compiler Strikes Back
Types and Neural Networks
Teaching AIs to color inside the lines — hype vs “we did this in the 80s”
TLDR: The post argues AI code generators should learn to follow code rules from the start, not just be checked after. Commenters split between “this is old news” (structural editors, early stopping) and “this is the right direction,” while practitioners warn real systems need enforceable contracts—making this debate more than academic.
Bruno Gavranović’s new post asks a simple question with spicy consequences: should we train AI code generators to follow the rules of code from the start, instead of fixing their mistakes after? He contrasts today’s “try, compile, repeat” loop with stricter, step‑by‑step checking—and wonders if models can learn to produce typed code natively. Read the cross‑post on the GLAIVE blog.
The comments? A riot. Skeptics like big‑chungus4 say the supposed fix sounds like the same old training trick in new clothes—“isn’t that just matching wrong code to right code with the usual loss function?” Meanwhile, the purists chime in: woolion shrugs that stopping early when a snippet can’t be completed is already a thing, dropping the irresistibly meme‑able phrase “proof tree with a hole.” Cue jokes about “donut‑shaped compilers.”
Then comes the retro‑tech mic drop: toolslive reminds everyone that 1980s structural editors on machines like the ZX81 literally wouldn’t let you type invalid code. Nostalgia meets snark: “Grandpa already solved this.” Others, like Daffrin, sober things up—warning that in messy real‑world systems mixing text and data, hidden rules between components break easily, and this whole type‑safety dream gets gnarly. And of course, the math mages arrive, with Xmd5a linking deep‑cut reads like “Neural Alchemy” and category‑theory backprop links galore.
Bottom line: half the crowd says “bold new blueprint,” the other half says “we’ve seen this movie”—and everyone’s arguing over whether the compiler should babysit the AI, or the AI should finally learn to clean its room.
Key Points
- •LLMs are typically trained for next-token prediction, producing untyped token sequences that are later parsed and typechecked.
- •The article frames post-training type enforcement along two axes: granularity (check frequency) and bandwidth (feedback richness).
- •The “Try; Compile; If Error Repeat” loop has low granularity and high bandwidth but wastes computation on unrecoverable early errors.
- •Tightening the feedback loop reduces waste but does not update model weights, so the model does not learn across sessions.
- •Constrained decoding consults the typechecker before each token to mask ill-typed continuations, aiming to enforce types during generation.