cardinal-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cardinal-dev] Compiler book review


From: Melvin Smith
Subject: [Cardinal-dev] Compiler book review
Date: Wed, 29 May 2002 02:07:19 -0400

In response to an earlier thread...
My take on compiler books.
Granted I've only written specialized compilers with simple languages,
but currently I'm expanding my horizons. Here is my real world experience
as a layperson; this is my library...


From best to worst:

1) Andrew W. Appel's "Modern Compiler Implementation in C"
A must have. A compact book, VERY straightforward, well written
and easy to follow. Any of his books are worth buying. You could
follow this book through from page 1 and incrementally digest
the subject. He doesn't stop at that, but gives some advanced chapters,
and covers garbage colllection as well. It's the thin, green book
with the tiger on it. He also has the same books for several other
languages.


2) Steven Muchnick's Advanced Compiler Design and Implementation
Not for the faint of heart and not for the beginner. However, it is without
a doubt in my mind, the best book in print for people that have written
a simple compiler, and then realize that the book they have tells them
zilch about how to do X, Y or Z. Includes the best chapter on register
allocation, period. Alternately, it includes a rather sad chapter on
"Code Generator Generators" which could be a very useful chapter if it
were fleshed out with a good example. Also one of the only books to
include real world case studies (Intel, Sparc, MIPS). Also great
chapters on optimization, pipelining and too much other stuff.
The BEST covereage of intermediate languages, period.
Another important fact, this guy ACTUALLY has designed
This is the book to own only after you own the Dragon book, or one of
Appel's books. Better is not necessarily simpler.


3) Dragon Book: Don't let either camp fool you. Its neither the end-all be-all,
nor is it useless enough not to buy. A surprising portion of my collection includes
complete books that mention, but never define terms such as LL(1), SLR, etc..
When I was struggling, I'd usually be able to pickup the Dragon and lookup
a definition. However, I find it a poor choice over Appel's books for
a beginner or first semester college course.

If I had to have 3 books, I'd choose the above.


In the "staples" category, these aren't complete compiler books, but
if you have one or two of the above, get these:

4) Parsing Techniques: A Practical Guide, Dick Grune, Ceriel Jacobs
The best compilation of parsing technology and terms that I know of.
And best of all, its now released by the authors for free download in PDF
format. No excuse for not having this one. :)

5) lex & yacc, (O'Reilly)
If you are going to work with lex/flex/yacc/bison, you should get this one.
Is mostly a reference book after you've gotten the hang of your first
compiler. A good piece on resolving conflicts in Yacc.

6) Mastering Regular Expressions, (O'Reilly)
Another invaluable reference, the best I know of. Does bias Perl a bit,
which is fine by me, but covers most other tools just fine. Good
description of DFA vs. NFA.

And in the "If you have money to burn" category:

5) A Retargetable C Compiler: Design and Implementation (AT&T lcc)
It looks pretty good at first glance, but the more I read it, the more
it is apparent that the authors rely too much on code to describe ideas.
Chapters on code generation were too fragmented, and should be
read along with the source code if you want to really understand
things like LBURG. Finally, they don't use standard tools (such as Bison)
so you'll learn little about using YACC derivatives. They use a recursive
descent implementation instead. It's great if you want to port lcc, but don't
make it your first, second or third choice.

6) Modern Compiler Design: A ton of material, but could probably be 10%
shorter. The authors have a very wordy way of explaining things. Its
the most difficult book to read out of all of these. The most confusing
explanation of L/S-attribute grammars I've read. Has some good
pieces if you are looking for something on a specific topic, and like (7),
is a good book if you want to write your own parser generator. Otherwise,
you can do without it.

7) Compiler Design in C, Allen Holub:  I haven't figured out how you
"design" something in C, but all I have to say is this book is almost a waste
of money. It's over 60% source code, from what I can tell. The author spends a lot
of time covering his own implementation of LALR generators (occs), which
is very valuable and is enough to buy the book. If you want to write a Yacc for
Ruby, this is one place to start. However, reading the rest of the book is about
as useful as scanning source code. Don't buy it.

        -Melvin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]