Dragon Book (Compilers)

Dot Net Perls
Compiler Principles

In this page, we review the famous dragon book, which is titled Compilers: Principles, Techniques, and Tools. The book was written by Aho, Lam, Sethi, and Ullman; the authors are professors of computer science at prestigious universities. While the dragon book does not describe popular programming languages or techniques—nor tell stories about dragons—it provides an amazing look at the lower levels of all software on all computers.

Key point: The dragon book teaches us about compiler theory, which can be applied to many aspects of computer programming.

Overview

The book largely describes the underlying theories of compiler construction, and how these theories are based on practical designs. In the appendix, the text provides a primitive Java compiler system; this is for illustrative purposes and not production. In other words, reading this book in its entirety will not give you any examples or tutorials for a specific programming language. It will instead give you a more complex understanding of how all source code is transformed into executables.

Runtime systems. The dragon book has an excellent and thorough chapter that describes runtime systems. These include memory allocation mechanisms, including heaps, stacks, and garbage-collection systems. Memory allocation algorithms are described in detail; several versions of garbage collectors are picked apart. While the chapter has no information about current systems such as Java or .NET, the describes are directly applicable to current runtimes.

Syntax-directed translation. In compiler theory, many phases are required to transition a source program into the target program, and syntax-directed translation is described as part of the solution. Although I have not covered all of this exhaustively, I have read overviews and many detailed sections.

Code generation. One of the phases in a compiler actually generates instructions in a sequential form from an intermediate representation. The dragon book describes three-address code, as well as other representations, used to take the meaning of the source code and transform it to instructions.

Note (please read)

Machine-independent optimizations. The chapter in the dragon book on machine-independent optimizations is really enlightening. It describes the usage of advanced mathematics, such as linear algebra and abstract algebra, to transform intermediate representations into faster forms. For example, sets of vectors are used to model iteration spaces. Further, loops can be conceptualized by iteration spaces, processor spaces, and data spaces. Arrays in loops can be modeled by their data dependencies, which indicates what elements are written to and read from.

Summary

We focused on the dragon book, also titled Compilers: Principles, Techniques, and Tools. While the dragon book does not provide practical tips for writing programs, it provides descriptions that lead to a deeper understanding of all software. Intermediate representations, translated through phases in a chain, provide a simplified view of this extraordinarily complex and artificial process. I offer an unconditional and emphatic recommendation for the dragon book.

Books About Programming