Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming IT Technology

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? "
This discussion has been archived. No new comments can be posted.

Good Books on Compiler Programming?

Comments Filter:
  • It's called "Advanced compiler design and implementation" by Steven S. Muchnick
    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.
  • 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).
  • 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.

  • Personally, when I took my first compilers class I used the book Crafting a Compiler with C by Charles Fischer and Richard Leblanc Jr. IMHO, it was also a bit dated, but really hit on the basic concepts, such as LL and LALR parsing. I think it may even go as far as peephole optimizations, but my class didn't get that far into the text.

    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.

  • Try "Writing Interactive Compilers and Interpreters" by P Brown. It doesn't go into huge detail, but warns agains all major pitfalls, and gives excellent hints on making your compilers usable. Aho Sethi and Ullman is very good, and nothing in it has stopped working due to age!
  • THe dragon book is simply one of the best books available for writing compilers. The main place it is lacking is in advanced optimization techniques, but I find it diffficult to believe you could get that far in a single semester.
  • That's the book that everybody told me to get when I took a compiler class, back in '91. However, I didn't get it (and ended up re-taking the class in '92, but that's another story :-) ).

    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.
  • Funny, I'm reading that book just now. It's right in front of me.
    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
  • 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.
  • Does anyone have suggestions on books that teach writing compiler compilers? I'm working on one that can parse/compile/execute anything from C++ to LISP to XML but as I've had no formal training in the subject and wasn't allowed to check out the one book I ever found that was good (and out of print, arghh) I'm mostly making it up as I go along and teaching myself from my own errors which is of course a very slow method. :)
  • This is the best book you can get and the best I've seen for Compiler courses. I don't know how technical your course is, but you may find some use for Le x & Yacc [amazon.com] ISBN: 1565920007.

    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!

  • I think the first thing you should check is lex & yacc. For what you are interested they seem to be ok. There is the "Lex & Yacc" book, cited in other comments, which is a good introduction to these tools, and introduce concepts you would learn in a "formal" class, like languages, grammars, etc. You should take a look.
  • by haahr ( 50664 ) on Tuesday March 07, 2000 @12:07PM (#1220774) Homepage
    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.

"The medium is the massage." -- Crazy Nigel

Working...