Many years ago, I did a stint as a compiler writer. I don’t do that
anymore but I’ve continued practicing what I learned by implementing
several little languages for various tasks. Mostly, I’ve leveraged
lex and yacc for those chores but my first little languages were
implemented using the simpler recursive descent technique for
parsing. Yacc is more powerful in the sense that it can parse LR(1)
languages in addition to the more restrictive LL(1) languages but
many or even most languages are LL(1) and certainly any reasonable
little language will be.
I mention all this because Hanspeter Mössenböck’s paper Compiler
Construction—The Art of Niklaus Wirth popped up in my RSS feed. Most
readers are probably familiar with Wirth as the designer (and
implementer) of Pascal and Modula{23} but he implemented many
compilers and is an expert on language and compiler design. The paper
is a retrospective on Wirth’s philosophy of language and compiler
design.
One of the things that popped out as me was his belief that compilers
should be simple, reliable, and fast and that he preferred that over
the heavy complexity that aggressive optimization brings. Ironically,
according to the paper Wirth’s compilers generated code that was
nearly as fast and those that did heavy optimization. He achieved that
by focusing on generating good code to begin with rather than
generating bad code and letting the optimizer fix things up.
He also preferred parsing with recursive descent because he felt it
forced the language designer to keep the language approachable and
simple. He believed that C would have been a better language if
Ritchie had restricted its grammar to LL(1) because it would have
avoided some of the syntactically dubious constructs that made their
way into the language.
If you have any interest in (computer) language translation—even if
only for little languages or DSLs—the paper is worth a few minutes of
your time. Also, Wirth’s book Compiler Contruction is available as a
PDF in many places such as here. The book expands on some of topics
that Mössenböck discusses in the paper.