Slashdot Mirror


Good Books on Compiler Programming?

Josuah asks: "I just started my CS164 Compilers class at the University of California, Berkeley and the book we are using is called Compilers: Principles, Techniques, and Tools by Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman, published by Addison-Wesley. Our professor told us today that the book kinda sucks because it is old (1988) but was unable to suggest a better book. Does anyone know of a good book on modern compiler programming? "

3 of 15 comments (clear)

  1. Ignore your prof. by Matts · · Score: 2

    This is _the_ standard text on compiler writing. What the book contains applies today and will apply in 20, 30 years down the road. Some of my books from Uni I still go back to, because the basic principals still apply (for example, the ancient "Principals of Concurrent and Distributed Programming" is still applicable in many modern situations).

    --

    Matt. Want XML + Apache + Stylesheets? Get AxKit.
  2. Compiler design hasn't changed that much by bhurt · · Score: 2

    Actually, it hasn't changed that much since the 70's. Primarily because there isn't much better that you can do- IIRC, parsing has theoretical computational limits (O(n)), and LALR(1) parsing is pushing those limits hard. It's the same reason sorting and searching are mostly dead subjects- there's not a whole lot better we can do, even theoretically.

    Aho, et. al. is the Dragon Book. That's one of the seminal references for compiler design. It doesn't get any better.

    The only other book I'd recommend is "Compiler Design in C" by Andrew I. Holub- which is actually more about the syntax analysis than the full compiler construction (it contains a simplified Lex & Yacc set of tools- for the same reason Tannebaum wrote Minix). Unfortunately, it's out of print. And you can't have my copy.

  3. Muchnick, Morgan, Appel, and Wolfe by haahr · · Score: 3
    Aho, Sethi, and Ullman is fine for the front-end of a C, Fortran, or Pascal compiler, but isn't very good if you care about interesting type systems or dynamic languages, and is absolutely awful for optimization in a modern compiler.

    Advanced Compiler Design and Implementation by Steve Muchnick is probably the best single book out there, if you don't care about parsing or other front-end issues. Almost all optimization issues are well covered. While writing a JIT for Java, this was the book I had open most often. My biggest criticism is that the algorithms are very high level and abstract: one I implemented ran in O(n^4) time as it was described, but with reasonable data structures was brought down to O(n log n) time.

    Robert Morgan's Building an Optimizing Compiler is also quite good. It covers mostly the same material as Muchnick's, but where Muchnick gives a survey of most major techniques in a given area, Morgan picks one and takes you through a pretty real implementation. It's not nearly as good a reference, but is definitely an easier read.

    Andrew Appel's Model Compiler Implementation in (ML|C|Java) is really good for the text, but the code is odd. Well, the ML code is fine and straightforward, but the Java and C versions will seem strange to people who don't write their code in ML and translate it to Java or C. If you want both front-end and back-end, though, pick one of these books. (His earlier, more hardcore Compiling with Continuations is very interesting, but not so practical anymore and only relevant for languages like ML or Lisp.)

    Michael Wolfe's High Performance Compilers for Parallel Computing covers the same turf as Morgan and Muchnick, but with a focus on parallel machines (though the scalar parts of the book are good, too). Definitely the first place to go if you really want to speed up matrix operations on MP or vector hardware.