“Code Reading: An Open Source Perspective“, by Diomidis Spinellis, is a new kind of book. It’s a foray into a domain normally left untouched by Computer Science texts and exemplifies yet another positive contribution from the Open Source movement. Simply put, Code Reading is a detailed discussion of the techniques required to read and maintain both good and bad code. As an interesting twist, the author draws on projects from the Open Source world to provide examples, both good and bad.Presentation
The book is approximately 400 pages long, and well packed with information. I found the text to be perfectly readable, if occasionally a bit terse. I wonder if perhaps this might have been rectified by splitting the book into two volumes, but then again as the first such book of its kind it would have been harder to gain acceptance in a multi-volume format. Source code is presented throughout the work, both in raw and diagrammed forms. Just by opening to a random page one can be assured of finding at least one source example, if not more. One of my favorite features is that this book, unlike many others, is not reserved about re-printing the same text. If the author has discussed some new method of analyzing an example, the example will be reprinted with the appropriate highlighting to mark the author’s point. This is a pleasant relief from any number of other books the expect the reader to picture the author’s discussion mentally.
The book is broken down into logical chapters, separating language independent notes from those dependent on the C language family. There are also handy indices of both code examples and tables, useful when you’re trying to find an example of that one construct you remember reading about. For those who might be using this in a classroom setting, there is a list of “maxims,” organized by chapter, in the appendices, as well as a thorough bibliography for those wanting to delve deeper. Also, every section features “Exercises” which provide suggested further studies and areas of code to look at. For instance, the section on test cases suggests using the “execve” regression tests (included on the CD) to derive the error codes provided in the man page. All in all, the book is thoughtfully organized for easy reference and study.
Source used in this book is drawn from across the Open Source world, though almost exclusively from projects using BSD-style licenses. While this is never said explicitly, I suspect the author wanted to be careful of possible licensing problems involving the more strict GPL, but nonetheless he has done an excellent job finding projects to suit his examples: projects such as Apache HTTPD & Cocoon, NetBSD, Perl, and XFree86 make appearances in the book, along with other smaller projects. Every project’s license is printed in the appendices, along with a small blurb describing each one. There is also a separate page crediting all the copyright-holders of the example code.
This book is not, however, for those looking to gain deeper insight into these specific projects. The examples are extremely localized and taken out of context. While the file name where each example occurs is given in the footnotes, only as much context is given as is needed to analyze the function of the snippet. In addition, all of the code used in the book is intentionally taken from older snapshots of the projects, so as to allow the author to point out now-discovered bugs, and to present the manner in which they were fixed. While this may disappoint those wanting to know just how Apache works, it provides useful examples on common bugs. In addition, all of the code used in the book is provided on a CD-ROM, for easy browsing.
In all, Code Reading is a successful beginning for a genre of technical writing that I hope will become more popular. It harks back to Lions’ Commentary on Unix, but in a more structured format. It shows yet again that Open Source can be used to fill another of the major gaps in the computing world, albeit in different manner than anyone originally intended.
The book is well written, and my only complaint is that at times the explanations can be a little terse, requiring repeated reading to fully understand it. I suspect this is due in part to limitations on the length of the book. I hope that future works on the subject will be able to expand on the places where information is limited in this.
My only other complaint is this book’s C-family centrism, focusing on C, C++, and Java. This is not in and of itself a bad thing, as most of the code written now is in these languages. I would, however, have liked to have seen some (even brief) discussion of other language families and how they relate to the maxims presented in the book.
In conclusion, I would recommend this book to anyone looking to become involved in the Open Source movement, as a good appreciation for the reading of code will be of immense value. Even more than that, I would recommend it to Computer Science students and professors, as it formalizes a skill that really ought to be taught in schools.
About The Author
Owen Anderson is an undergraduate Computer Science student. He studies algorithms and advanced logic, and is also interested in databases. He uses Windows XP and Mac OS X Panther on his desktop computers, and administers a Gentoo Linux server. He considers himself proficient in C, Objective-C, and Java, with dabblings in all kinds of other things.