Yacc is Not Dead (2010)
5 points by runxiyu
5 points by runxiyu
It's 2026 now and I think I'm comfortable calling yacc dead. If it's not, it should be. If anyone is still using it they should stop, and find a newer parser generator or roll their own. It's VERY archaic by current standards, and LR/LALR parsing's restrictions are a huge downer.
Oddly enough, I was about to cobble together a DSL, and use Yacc for its parser. Simply because it is easy from an experimentation perspective. Why would I bother to choose something else?
If the experiment goes anywhere, the parser would then be replaced by something else, possibly a simple recursive descent one.
Simply because it is easy from an experimentation perspective. Why would I bother to choose something else?
For people unfamiliar with Yacc, I think tree-sitter would be an easier choice for experimentation due to (1) the better error messages, (2) the docs and tooling (3) use of a familiar-ish language (JS) to define the grammar instead of a custom language.
Is it easy? If you're after experimentation experience rather than performance, why not treesitter or some peg parser? They're less... weird with state and priorities.
You might be the first person in the history of language design to choose yacc because it's easy. Generates fast output? Sure. Widely supported? Absolutely. Easy to use? Not unless your alternative is hand-writing a parser in assembly. I honestly can't think of a single way of writing or generating a parser that is harder to use than yacc.
Totally agree. I think unfortunately yacc survives well in university introductory courses to compilers.
Not everything that is old is bad. My main quibble with Yacc (beyond minor syntactic things) is that it automatically "resolves" some conflicts, and I think users should be forced to confront each one, because they're nearly always a sign that there's a deeper flaw somewhere.
Separately, there are parsing algorithms. While LALR is pointlessly restrictive, it's worth remembering that LR is the biggest unambiguous subset of grammars we know how to define and there is real worth in that. Guy Steele's words still capture wisdom that is relevant today IMHO:
I use Yacc constantly as a check of all my language designs, but I very seldom use Yacc in the implementation. I use it as a tester, to be sure that it’s LR(1) … because if a language is LR(1) it’s more likely that a person can deal with it.
Yeah it’s annoying that LALR introduces spurious conflicts, and although a fix was published in the 1970s many textbooks still describe the buggy algorithm and many yacc-style tools default to LALR.
https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/parsing/#stop