on May 18, 2007
I spent some serious quality time with the first edition (the "red dragon book"), in three main episodes over the past dozen years: 1) undergraduate compilers class, 2) industry project, and 3) parser generator implementation. During all three episodes, I was disappointed in various ways, though there is no denying that the book contains a wealth of information. As an undergraduate, I found the book somewhat impenetrable. When in industry, I found the book too abstract. When implementing a parser generator, I discovered that the book excludes important research results with regard to LR parser generation. It is the last disappointment that I will focus on.
The book presents parser generation in layers of increasing complexity, from SLR to LR to LALR, where LALR is presented as the penultimate algorithm, though LALR parsers can only handle a subset of the grammars that LR can handle. The justification for this is that the original Knuth LR algorithm is intractable for large grammars. However, an efficient, fully correct, approach for LR parser generation was published in 1977, and on top of that it appears easier to implement than efficient LALR parser generation! The red dragon book's original authors simply cannot have been unaware of this research result, but I suspect that they elected to warm over the "green dragon book" (published in 1977) rather than incorporate the state of the art as of 1986 into the "red dragon book". Now here we are another 20 years later, and as near as I can tell from reading through available online information, the "purple dragon book" is perpetuating this omission. The result of the red dragon book is that we have an entire generation of computer scientists who have been mislead to think that LALR is somehow superior to LR, and the purple dragon book is setting things up for yet another generation to be mislead.
on January 13, 2012
Aho, Ullman et. al's "Compilers" is a fantastic book and well worth studying for all computer programmers - implementing a compiler compiler will yield tangental benefits to anyone who writes programs for a living or for fun.
However, the Amazon Kindle edition of this book is *awful*. First and foremost, I discovered at least one error in an algorithm that is not present in the standard edition that causes the book's proposed algorithms to be incorrect (in this case, it was algorithm 4.31 - in step 1, you should compute FIRST(alpha), not FIRST(A).)
On top of that, there are spacing issues and font issues throughout the book. It appears that in many places where the standard edition had a word separated across lines, the Kindle edition merely has that word split in two with a space between its halves. Worse, the font choice used to typeset algorithms doesn't easily distinguish many greek lowercase letters from their modern English equivalents, the result being that it is fiendishly difficult to understand some algorithms (the book uses greek letters to indicate a 'sentential form', so they appear a *lot* and tend to be right next to their modern equivalents.)
In other words, I would give Compilers (the Standard edition) a 5/5 (or maybe a 4/5 - it could stand to use a bit more real-world code), but this Kindle edition is rubbish and you SHOULD NOT BUY.
on March 14, 2000
During each compiler stage (lexical analysis, syntax analysis, translation, type checking, translation, code generation, and code optimization) multiple methods, strategies, and algorithms are presented. This comprehensive book examines items that are unique to the various languages presented (Fortran, C, and Pascal); there are even sections on dealing with estimation of types (10.12) and symbolic debugging of optimized code (10.13). Wow! The exercises are thorough, challenging, and thought provoking. Examples are interleaved with the discussion and algorithms. There is an excellent set of historical and bibliographic information at the end of each chapter. The use of automated tools such as lex, yacc, and compiler-generators is discussed throughout the text. This is an advanced book, however a good understanding of compilers can be obtained without understanding the details of every algorithm.
on April 19, 2002
Once again, I want to point out the title of the book: "Principles, Techniques and Tools".
I think there are two kinds of compilers books available today: "Principles and Theory centered" ones and "Modern Compilers design and implementation" ones.
One might wonder what's the difference between the two.
The former kind is more suited for a course on theoretical aspects that lay the foundation of compiler construction. DFAs, NFAs and Regular expression along with relations and equivalence between the them; FSAs minimizations; grammars and Push-down FSAs in details, ambiguities and and how to cope with them; and so on.
This is what I mean for "theoretical aspects". And these topics are covered in great details in this book. Almost the same details they (the authors) placed on writing a more specific book as "Introduction to Automata Theory ...".
Same situation applies to principles on more application- oriented topics. Take the example of LR parsing. You can face the topic from a more theoretical side, dealing with details on bottom up parsing (still, it implies an in-depth knowledge of grammars theory), handles and (viable) prefixes, SLR or canonical LR or LALR parsers and techniques for the relative tables construction by hands (and for this, add a detailed and solid knowledge of Push-down FSAs along with grammars). By hands, at least, if principles are what matter in your course.
If you expect to find these topics (with this depth) in a book of the other kind, you might get mislead. As I did when I still had not clear this distinction, before I took the course.
The latter kind of books is more suited for a more pragmatic course. One where real, "modern" compilers are at hands, and probably written as homeworks. In this case, time being always limited in a university course, one (the instructor) will likely have to give up with those theoretical aspects (or just mention them) and focus on coding techniques and modern compiler studying. But ... perhaps, for these purposes books like Grune's "Modern Compiler Design", or Pittman's "Art of Compiler Design, The: Theory and Practice" or, at some degrees, Muchnick's "Advanced Compiler Design and Implementation" will be more suited.
Back to the LR parsing example, more pragmatic compilers design courses will (for time constraints) just have a glance on principles and spend a considerable time learning YACC. To do both things you would have to take a course on YACC alone (it requires time to exploit all of its advanced features, you can be sure of this).
All this said, once again: which is the best book ? The one that best fits your needs. And in fact, my needs were those of my course, which was completely centered on theoretical aspects. And for this course, the Dragon book (as it is better known since its cover) proved to be perfect, definitely no matter it was published on 1986: FSAs and grammars and their theory is (for all practical purposes) still the same since even before then.
on September 28, 1999
This is a comprehensive and easy to understand text. It covers all the fundamental stages of compiler design, with plenty of explanation (both practical and theoretical). It doesn't exhaustively cover every conceivable topic, but it does leave you with a good taste of what's involved. Of course, it is not a book for beginning programmers, and there are very few code examples. Judging by the comments of some reviewers, I would suspect that they gave poor reviews because they lacked the prerequisite background (familiarity with a good HLL like C, data structures, mathematical background etc). As with any 'advanced' topic in computer science, there is quite a lot expected from you. Upon first reading, some topics occasionally seem overwhelming. Welcome to Earth. This is where your library card comes in. Do a little research and then come back to this text; you'll find that it is well organized and extremely clear. If you want a cookbook this book isn't for you. If you want a solid understanding of compiler fundamentals then this book is your best bet.
on July 6, 2009
I wrote a complete complier as a semester project 30 years ago using the Green Dragon book. (I had written a parser generator the semester before, otherwise I could never have done a compiler on my own in one semester.) Doing that resulted in a tremendous sense of accomplishment and a feeling that I could do anything with computers. A feeling that has remained with me since then.
If you are not a computer science major and are just looking to implement a simple compiler, perhaps there would be books with less theory that might still get you to produce a compiler and that would be easier.
On the other hand, if you are a computer science major (or several related fields), your CS knowledge will be greatly enhanced by writing a compiler. And this book or some future edition of this book should be your guide.
To the people who mention some of the newer books that cover a lot of the newer techniques and technologies, I say, it doesn't matter to most people. Most people will only write a fairly simple compiler. Unless you are going to work for Microsoft developing the next version of Visual Studio, you don't really need most of those developments. Compiler construction is complex, and if you're learning about RISC, you're probably not learning enough about LALR. Both will be useful to know, but I think it's reasonable to not burden a compiler class with too advanced topics.
on February 23, 2006
A great book, which covers all you need to write a decent optimizing compiler.
However, it's dated. It doesn't cover single static assignment, advanced control-/data-flow techniques, or instruction scheduling. It predominantly focuses on flat quads or binary tree representations, and a good third of the book covers the theory of scanning and parsing, which nowadays are almost exclusively handled by scanner/parser generators.
I'd instead recomend "Advanced Compiler Design and Implementation" by Muchnick, or "Engineering a Compiler" by Cooper
on January 31, 2007
This book has the reputation as being THE book on compilers. I'll grant that. It covers everything and the kitchen sink, at a theoretical level. This is NOT the book on implementation details. Without prior exposure to the basic principals and problems in compiler implemenation, it can be difficult to see why the theory, as presented, is relavent. Why is left recursion bad? What good are handles? How is the type system significant? How do symbol tables relate to scoping? This stuffs in there, but if one is not expecting it, one won't appreciate the terse presentation. But that's the kind of learner I am, I have to know why something is relavent before I get it. So, I don't recommend this book as a first book on languages and compilers.
For those interested in the more general and theoretical principles behind compilers, this book can still serve as a good introduction in that regard. More modern treatments are available to those who need more information on modern developments in compilers, such as optimization, partial evaluation, etc. The book covers lexical analysis, parsing techniques, syntax-directed translation, static semantic checking, type checking, unification, target code generation, and compiler code optimization. All of these are discussed in great detail, the C language is chosen to write the compiler coding, and numerous exercises are put at the end of the each chapter. The reader can also gain an insight into the historical origins of the subject.
on July 20, 2001
"Compilers: Principles, Techniques, and Tools" (Aho, Sethi, Ullman) is a very comprehensive, detailed description of compiler technologies. Because of its great detail, you may have to take a different approach to reading this book than you would a normal programming book.
My first tip is to read the book more than once. With this in mind, it is useful to do your first reading in segments (i.e. not every page of the book). My tip is to follow the example lesson plan provided in the front of the book. It will direct you to chapters that would be used in a Compiler class. Once you have done this lesson plan, you can re-read the book from start to finish to get those extra details hidden within.
If you try to read this book in its entirety on your first try--intending to successfully grasp all of its contents--this will be difficult. My recommendations above will help those out there that want to learn about this technology, but haven't had experience with compilers before to read this book in a way that lets you absorb the great amount of information.
Other than the reading approach, a good mathematical background (algebra II and above) is recommended for grasping some of the concepts mentioned within. Also, a basic knowledge of common Computer Science concepts (binary, assembly, stack, etc.) as well as a familiarity with using compilers and multiple programming languages is very useful.
Although the book may seem overwhelming at times, with careful consideration and time spent following these guidelines, it can be done. I'm only 15 years old and have started embedding some of these concepts into my applications.
Good luck to all who read this book and happy programming!