Good Books on Compiler Programming? 15
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? "
ISBN 1-55860-320-4 (Score:1)
It's not very formal and shows a lot of programming details, but on the whole it's a good book, it doesn't discuss parsing and emitting and such but more the optimizations and transformation applied to intermediate representations inside the compiler.
Ignore your prof. (Score:2)
Copiler Design Texts (Score:1)
Aho, Sethi & Ullman is a very good book, though some people think it's a bit unreadable. My personal favorite is Allen I. Holub's Compiler Design in C from Prentice Hall, which is more readable than Aho etc. without sacrificing any of the details. Another text, and the one that got me interested in compilers, is James E. Hendrix's A Small C Compiler from M&T Books which is also very readale by much less technical than Holub or Aho etc.
Under any circumstance, your prof is blowing a little bit of smoke up your ass with the talk of Aho, Sethi & Ullman being outdated just because it was written in 1988. Most of what we know about compiler design was known by the mid-sixties, if not before (some FORTRAN compilers were Really Good (R), even if many early C and Pascal compilers sucked). Although there was some progress made in the seventies and eighties, the state of the art hasn't changed all that much in the past ten years.
The books I've used (Score:1)
On the other hand, the recent incarnations of that class seem to be using Modern Compiler Implementation in {C/Java} by Andrew Appel, but I can't speak for it firsthand.
With a bit of hindsight, and the approaches I learned in my second Compilers class, I would say that real compiler frameworks are built using tools like lex, yacc, bison, or Eli [colorado.edu]. But still, you need the basics from handwritting a parser to really appreciate how these tools work.
Re:Compiler Design Texts (Score:1)
The Dragon Book (Score:1)
The Dragon Book -- Standard Reference (Score:1)
I got a terrific book, but I can't remember the title/author to save my life. It's a large format (maybe 9x12"), blue cover, and thin (maybe 100 pages), but it was a godsend -- lots of good examples, etc. Not so much theory as practical applications and examples.
I'll try to remember to look for it tonite at home.
david.
Re:The Dragon Book -- Standard Reference (Score:1)
Compiler Construction by Niklaus Wirth
A very good, up-to-date quick book. Uses an emulated risc instruction set for a target. Plus, it's A LOT cheaper than the Dragon Book.
-Corey O'Connor
Compiler design hasn't changed that much (Score:2)
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.
Compiler compilers? (Score:1)
The Dragon Book (Score:1)
That book will help you tremendously if you need to actually write a compiler. But don't neglect the dragon book. It's somewhat hard to follow sometimes, so make sure you go to clas too!
Re:Compiler compilers? (Score:1)
Muchnick, Morgan, Appel, and Wolfe (Score:3)
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.