
Engineering a Compiler, 2nd Edition is out - mattyb
http://www.elsevierdirect.com/product.jsp?isbn=9780120884780
======
haberman
I repeat my criticism: I reported an error in the book _twice_ to the email
address that was specified for "errata," and never heard anything back:

<http://news.ycombinator.com/item?id=1643787>

I would hope that they have corrected this error in this version of the book,
but their non-response to my report does not give me hope.

~~~
simplegeek
I've not read the book so I'm not sure how good it is. However, at times
authors don't reply but they do include your name with acknowledgment so did
you check the new edition? But if that didn't happen, then I totally agree
with your sentiment.

~~~
haberman
They have a list of errata for the first edition, and it makes no mention of
my correction:

<http://www.cs.rice.edu/~keith/Errata.html>

------
pbiggar
I love this book! I have (or had) about 7 compiler books, and this was always
my favourite (another notable is Programming Language Pragmatics, and also
perhaps Modern Compiler Design in X).

For beginners, this book rocks. It's readable, very well written, and very
easy to follow. For intermediates, it has tons of interesting asides and
anecdotes.

(All this applies to the first edition - I haven't read the second).

Finally, many people recommend the Dragon Book; I really really could not
recommend it less. Buy Engineering a Compiler instead - there is really no
comparison.

~~~
kanak
Could you please suggest a list of books to read in sequence to learn about
building compilers? Thanks.

~~~
pbiggar
I'm not sure about reading the books in sequence (I haven't tried it), and
after a short period you'll probably find yourself referring to the papers
they reference. I've heard good things about this as a first step:

<http://news.ycombinator.com/item?id=1408241>

Otherwise, I'd recommend Engineering a Compiler, or Modern Compiler Design in
X by Appel (where X is one of the languages in which the book is offered).

------
pella
good compiler books for the begginers:

[http://pragprog.com/titles/tpantlr/the-definitive-antlr-
refe...](http://pragprog.com/titles/tpantlr/the-definitive-antlr-reference)

[http://pragprog.com/titles/tpdsl/language-implementation-
pat...](http://pragprog.com/titles/tpdsl/language-implementation-patterns)

~~~
istjohn
Another, but free: Compiler Construction (<http://www-
old.oberon.ethz.ch/WirthPubl/CBEAll.pdf>)

~~~
shadowfox
Wirth is a bit out of date imho

~~~
istjohn
I don't really know, but the book seems pretty basic. I would be surprised if
any of the compiler ideas it covers were actually obsolete. They might be
simplifications, but they are likely still useful to someone new to the
subject. The concrete elements of the book definitely aren't shiny new. The
example self-hosting compiler is implemented in a Pascal-like language called
Oberon and targets a virtual RISC architecture. But I think the essential
ideas behind compilers are the same today as they were fifteen years ago.

~~~
sb
I agree that it is the best book on compilers for beginners. I think that
parsing using a recursive descent parser for LL grammars with attributed
grammars teaches you the most basic and important things (such that one is
able to design and parse a nice DSL.)

Having said that the book's major draw back is that is "soft" on the major
topics of today: optimizations. The book is very frontend centered and
mentions some possible optimizations in the final chapter--no implementations
given. Hence, while I always recommend this book as the first go-to book,
interested compiler programmers _have_ to find supplemental material
elsewhere. (I love M. Scott's "Programming Language Pragmatics", respect
Grune, Bal, Jacobs and Langendoen's "Modern Compiler Design", consult
Muchnick's "Advanced Compiler Design and Implementation".)

Topic-wise, supplemental material to Wirth's CC-book, I suggest: LR-parsing
(yacc) and in-depth study of instruction selection ([i]burg) and register-
allocation (graph coloring) for important backend optimizations. I think that
gives a firm understanding of compilers, suitable for further study (such as
Muchnick "Advanced Compiler Design and Implemetation" 1997 or Morgan "Building
an Optimizing Compiler" 1998.)

------
jbarham
If you want to look at a real-world compiler, check out the Go suite of "gc"
compilers, which are mostly written by Ken Thompson. The source for the Go ARM
compiler is at <http://golang.org/src/cmd/5g/>, or you you can browse the
entire Go source tree at <http://code.google.com/p/go/source/browse>.

The Go compilers are very fast. For most of the code I've developed (several
hundred lines per package) I rarely have to wait more than 0.1 seconds to
compile _and link_ on my 2.4GHz i5.

~~~
singular
Agreed, go rocks :)

Keep in mind that a lot of the logic is shared between backends, so check out
<http://code.google.com/p/go/source/browse/src/cmd/gc> for the core stuff too.

------
SMrF
Edit: Ignore this entire comment. I've been reading a different "engineering a
compiler" subtitled, "vax-11 code generation and optimization". Which, as I
explained is very interesting, but certainly not really for a beginner. Now I
just need to get a copy of the actual "Engineering a Compiler" everyone has
recommended I read. :-)

I've just started reading this book, (older edition), after reading many
recommendations that it would be a good place to start for beginners. I find
it is an enjoyable read, but I don't really feel like I'm learning how to
write a compiler. Much of the text seems devoted to the experience of
wrestling with the restrictions of the technology of the day, (e.g. compile
times were 12-24 hours because they had to wait for tapes generated by one
half of the compiler at one location to be couriered to another location to be
finished). I find this fascinating, but it's not really helping me learn to
write a compiler. On top of that the solution and code is very close to the
metal, which again I find to be fascinating but not incredibly educational.

I want to write a templating language in Haskell as an exercise to learn
Haskell and get my feet wet with compilers. What's a good book for me?

~~~
st3fan
I'm in the same situation and I just ordered a copy of:

[http://www.pragprog.com/titles/tpdsl/language-
implementation...](http://www.pragprog.com/titles/tpdsl/language-
implementation-patterns)

------
itsnotvalid
It would be nice to learn about new compiler internals. I wonder though, how
many of us would need to work day to day on a compiling language (as comparing
to intercepted or JIT languages.)

BTW, why not getting that @ amazon? At least you get 20% of in the US (but
only get the book by March)

(The worst plug here for my own amazon link, you are warned, please don't vote
this down just for the link: <http://amzn.to/fpNazO>)

~~~
MichaelGG
Isn't much of the engineering of a compiler the same, regardless if machine
code or intermediate VM code is emitted?

~~~
kingkilr
Just outputting something isn't particularly different whether it occurs at
runtime or "compile" time. However, if you want to know how to execute Python
efficiently that's a very different topic than how to execute C efficiently.

~~~
itsnotvalid
If anything has to be language/platform/framework specific, it would not be at
the compiler level. There are just some many things that could affect the
performance of some code, it would be naïve to simply looking at things on
compiler level.

~~~
kingkilr
I was speaking more generically about a highly dynamic vs a highly static
language, using Python as an example. The same comment applies to Ruby or
Javascript.

~~~
itsnotvalid
Yes you are right. So in general we should read this book.

------
serichsen
I must admit that Elsevier is such a red rag for me that I did not even
consider visiting that site, even though I find the topic interesting.

