Programmer's Book Review

C/C++ Users Journal July, 2004

By Jack J. Woehr

Jack J. Woehr is a consultant and can be contacted at http://www.softwoehr.com/softwoehr/.

C & Data Structures
P.S. Deshpande and O.G. Kakde
Charles River Media, 2004
700 pp., $59.95
ISBN 1584503386

Advanced UNIX Programming, Second Edition
Marc J. Rochkind
Addison-Wesley, 2004
736 pp., $49.99
ISBN 0131411543

C& Data Structures, by P.S. Deshpande and O.G. Kakde, is an undergraduate introduction to the C language and its data structures. It is divided into three sections: one on the basics of the language, one on data structures, and one on advanced problems in data structures. The book is a quite reasonable and well-paced introduction to the subject matter, teaching by exposition and by example in a fashion well suited to its target audience. The C language is expounded in brief, with an especial eye to syntactic peculiarities such as expression evaluation. All the classic data structures are present, those most fundamental to any real-world C program: stacks, queues, arrays, linked lists, and so on, up to the eight queens problem. They are explained in theory, layout, and implementation in rather straightforward examples.

Although no biographical material is included in the book, it seems graduate students assisted the authors (their professors?) in the preparation of example code. The writing is simple, engaging, and stays within the bounds of international technical English. The book is of medium-high production values: It is reasonably attractive (a better font allowing better formatting could have been found for the example code), easy to handle, moderately well proofread (linguistic glosses appear, such as "courses" for "causes"), and somewhat indifferently indexed.

The authors of C & Data Structures occasionally exhibit a penchant for formalism. For example, Chapter 25, a 45-page treatise on problems in linked lists, closes with four "Points to Remember."

I advise students to remember point four. Until retirement, they will most likely never again have use for points one through three outside academia.

The book comes with a CD-ROM containing some, but apparently not all, of the source code in the book. The content is divided, like the book, into three sections, but some examples seem to be absent. Although the examples are in Standard C, this is another one of those CD-ROMs created for a world in which only Microsoft Windows exists, complete with lack of any indexing system other than directories, an autorun program of some sort for Windows, and an unfortunate choice of filesystem that renders example names in the form "bestn~10.c", "conne~12.c", and so forth.

Most of us have gained weight over the past 20 years, and so has Advanced UNIX Programming since its first edition (1985). For that matter, so has UNIX, which has a lot to do with why a second edition of this classic was long overdue. Author Marc Rochkind was working at Bell Labs before he wrote the original book, went on to found XVT (he's no longer there), consulted here, programmed there, and eventually took two full years to write the second edition of the book.

Advanced UNIX Programming, Second Edition, is a complete course in programming the UNIX operating system from the ground up, with an emphasis on examples. If you have found the monumental and austere works of W. Richard Stevens a bit steep and wished for a more reader-paced exposition of the same truths, the 700+ pages of Advanced UNIX Programming yield a favorable comparison to the 2800+ pages of Stevens.

Not much remains of the original book (or of the original UNIX) except the chapters about character terminal programming. The second edition is pretty much entirely rewritten with an emphasis on the standards and techniques for writing portable UNIX programs. Gone is advice about maneuvering around kernel deficiencies of early UNIX systems. Welcome in new sections on pseudo-tty's, interprocess communications, POSIX semaphores, threads, and the like.

"In the second edition," Rochkind tells me, "I have new ways of talking about things. I don't even say that a signal is sent to a process, I say that the signal is sent to a thread. I make threads a first-class citizen in the book because that's the way to think of the system now. But there are two properties of the old book which I retained: One, pretty much every system call appears in an example. And secondly, all error checking has to be real. I never skip checking for an error on the excuse that the example is easier to read, because my belief and experience is that people will copy code out of the book. I didn't want them pasting anything into their code that wasn't right. Readers can skip around the book, but don't skip Chapter One, or the rest of the book will be baffling because of the macros I introduce in Chapter One for error handling."

The code has been tested on Solarix, Linux, Mac OS X, FreeBSD, and HP/UX. Rochkind is currently working on an answers manual for the exercises in the book, intended for computer science professors who wish to use Advanced UNIX Programming as course material.

Although C, specifically C99, is the language of reference in the book, Rochkind informs me that he never expects to have to write an application again in C—currently he's developing in C++ and Jython. To that end, he has designed Jtux, a Java interface to most of the POSIX/SUS system calls. Jtux is described in Appendix C of the book and is open source under the BSD license.

The author's web site for the book is http://basepath.com/aup/ and includes example source code, the source for Jtux, errata for the book, along with other articles and resources. Rochkind plans a reader forum as a central repository of answers about the book and about Jtux. The publisher's web site for the book is http://awprofessional.com/title/ 0131411543.