Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Introduction to compiler construction in a Java world
Campbell B., Iyer S., Akbal-Delibas B., Chapman & Hall/CRC, Boca Raton, FL, 2013. 381 pp. Type: Book (978-1-439860-88-5)
Date Reviewed: Sep 10 2013

In a random, unscientific sampling of syllabi for recent compiler courses at a dozen universities in the US, I determined that many still use the iconic “dragon book” [1], or older textbooks from as far back as 1995. Several of the syllabi mention the more recent compiler text by Cooper and Torczon [2], but the older books seem to prevail. However, this new book’s fresh, readable, student-friendly text and supporting software make it a serious contender for both self-study and classroom adoption.

While this 350-page book is no replacement for the comprehensive coverage of the 1000-page dragon book, the 800-page Cooper and Torczon text, or a number of other textbooks in compiler design, it allows the reader to quickly become involved in every stage of the compiler construction process. The heart of the authors’ pedagogical approach is having the reader make modifications and additions to a working compiler, written in Java, for a subset of Java that the authors call j--.

In the first chapter, the reader is led through the steps needed to add an integer division operator to j--, from creating the JUnit test files, through augmenting the scanner and parser, to generating the appropriate byte code. Exercises at the end of the first chapter encourage the reader to implement some of the other missing operators by imitating this process. (The “DivisionTest” code in the book is wrong, but the authors have posted an errata file containing corrections to this and other errors.)

The compiler source code is available on the authors’ website. It was easy to install using the instructions provided there, and it worked out of the box. It uses a recursive-descent parser, and includes back-ends for generating both standard Java virtual machine (JVM) byte code and MIPS assembly language. There are compiling options for examining the tokens, the abstract syntax tree, and other intermediate states of the compilation. The j-- language is rich enough to permit fairly sophisticated programs while still allowing much room for experimentation and expansion. For instance, it has integer, Boolean, and string types, but no floating point; it supports Boolean “not” and “and,” but not “or”; it allows “while,” but not “for”; and it permits programs with multiple classes and inheritance, but does not include interfaces.

Much, if not most, of the work required of readers of this book lies in understanding the existing code for the j-- compiler. Consequently, many of the figures in the book consist of Java methods for accomplishing various compiling tasks. Students who would rather write code than read it will prefer to use a different book, but other (perhaps most) readers will appreciate having a stable and robust code base to serve as the foundation for their explorations.

There are separate chapters devoted to the theory of lexical analysis, parsing, and symbol tables and abstract syntax trees, all presented both formally and through the example of the j-- compiler. JVM and MIPS code generation receive a chapter apiece, and another chapter addresses register allocation. Elementary code optimization techniques are described in the MIPS chapter. The concluding chapter surveys several “celebrity” compilers, including a few Java compilers and the Microsoft C# compiler. Each chapter has a rich set of exercises that reinforce the material well. Good software engineering principles are emphasized throughout the book. Two of the five appendices describe the syntax of the Java and j-- languages, and another gives a thorough introduction to JVM and class files.

This would be an excellent book to use for individual study or in an upper-level undergraduate or first-year graduate course. No previous background in the theory of computation is needed, but a solid Java background is essential and some previous experience with programming languages (scope, stack allocation, types, and so on) would be useful. Knowledge of assembly language programming will be helpful if the course will include the chapters on register allocation and translating to MIPS.

More reviews about this item: Amazon

Reviewer:  R. Roos Review #: CR141531 (1311-0962)
1) Aho, A. V.; Lam, M. S.; Sethi, R.; Ullman, J. D. Compilers: principles, techniques, and tools (2nd ed.). Prentice Hall, Boston, MA, 2007.
2) Cooper, K. D.; Torczon, L. Engineering a compiler (2nd ed.). Morgan Kaufmann, Burlington, MA, 2012.
Bookmark and Share
 
Compilers (D.3.4 ... )
 
 
Java (D.3.2 ... )
 
Would you recommend this review?
yes
no
Other reviews under "Compilers": Date
An architecture for combinator graph reduction
Philip John J., Academic Press Prof., Inc., San Diego, CA, 1990. Type: Book (9780124192409)
Feb 1 1992
Crafting a compiler with C
Fischer C., Richard J. J., Benjamin-Cummings Publ. Co., Inc., Redwood City, CA, 1991. Type: Book (9780805321661)
Feb 1 1992
A methodology and notation for compiler front end design
Brown C., Paul W. J. Software--Practice & Experience 14(4): 335-346, 1984. Type: Article
Jun 1 1985
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy