News for hackers. Stuff that matters.
Re:If I ever design a first course in compilers, I'll do it ... by Rusky on Thursday August 07, 2014 @11:52AM (#8148349)
If you want any chance of understanding real compilers, the "optional" optimizations and parsing algorithms are actually pretty important. I do think starting with an interpreter for an AST is just as good a method as starting with code generation, and code optimization can probably wait until the end, but teaching parsing should avoid any kind of CYK/LL/LR unless you're specifically teaching grammar theory.

Using a parser generator of some kind is possibly okay to teach the concept of a grammar, but it's terrible for error handling, efficiency, and simplicity. For most programming languages, nothing beats a plain old hand-written recursive descent parser (optionally with pratt parsing for expressions) on those metrics. And indeed, most compilers I've seen in production are written that way.

There are no comments on this comment yet.