TITLE: The Role of Parsing in a Compilers Course AUTHOR: Eugene Wallingford DATE: April 05, 2013 3:21 PM DESC: ----- BODY: I teach compilers again this fall. I'm looking forward to summer, when I'll have a chance to write some code and play with some ideas for the course. This morning I thought a bit about a topic that pops up every time I prep the course. The thoughts were prompted by a tweet from James Coglan, which said "Really wish this Compilers course weren't half about parsing. ... get on with semantics." The ellipsis is mine; James's tweet said something about using lex/yacc to get something up and running fast. Then, presumably, we could get on to the fun of semantics. This is a challenge for my compilers course, too. I know I don't want to rush through scanning and parsing, yet I also wish I had more time for static analysis, optimization, and code generation. Even though I know the value of parsing, I wish I had equal time for a lot of other cool topics. Geoff Wozniak's response expressed one of the reasons parsing still has such a large role in my compilers course, and so many others:
Parsing is like assembly language: it seems superfluous at the time, but provides deep understanding later. It's worth it.
That's part of what keeps me from de-emphasizing it in my course. Former students often report back to me that they have used their skill at writing parsers frequently in their careers, whether for parsing DSLs they whip up or for making sense of a mess of data they want to process. A current student is doing an undergrad research project that involves finding patterns in several years of professional basketball play-by-play data, and his ability to parse several files of similar but just-different-enough data proved invaluable. Of course, he was a bit surprised that corralling the data took as much effort as it did. Kind of like how scanning and parsing are such a big part of a compiler project. I see now that James has tweeted a retraction:
... ppl are RTing something I said about wishing the Compilers course would get done with parsing ASAP. Don't believe this any more.
I understand the change of opinion. After going writing a compiler for a big language and learning the intricacies that are possible, it's easy to reach Geoff's position: a deep understanding comes from the experience. That doesn't mean I don't wish my semester were twenty weeks instead of fifteen, so that I could go deeper on some other topics, too. I figure there will always be some tension in the design of the course for just that reason. -----