Classic UNIX Programming Text Updated

By: Ibrahim Haddad
Tuesday, July 5, 2005 12:18:35 PM EST
URL: http://www.linuxplanet.com/linuxplanet/reviews/5918/1/

Interview with Steve Rago, Co-author of Advanced Programming in the UNIX Environment

After 13 years, Addison-Wesley has published an update to a classic UNIX System programming text: Advanced Programming in the UNIX Environment. After the death of the original author, Rich Stevens, in 1999, it was difficult to find someone to tackle a project this big. We recently caught up with the co-author, Steve Rago, to get a behind-the-scenes look at this project.

Steve, you were one of the developers of UNIX System V Release 4. Can you tell us more about your background and contributions and how you became the co-author of the second edition of one of the most popular UNIX books?

After getting a BE and MS from Stevens Institute of Technology, I got a job working in the UNIX System V Development Laboratory at AT&T Bell Labs. I had wanted to work at Bell Labs, where my father worked, since I was 12 years old. Ironically, a year after joining Bell Labs, AT&T reorganized us into a different business unit, so we weren't Bell Labs anymore. I started out working on System V Release 2.0, helping to maintain and benchmark the VAX port. Eventually, I worked on networking software, which led me to STREAMS. After most of the original STREAMS developers completed the port of Dennis Ritchie's streams to System V Release 3, I ended up taking over responsibility for it somewhere between SVR3.1 and SVR3.2. During SVR4 development, I enhanced the STREAMS mechanism, converted the open file table to use dynamically-allocated memory (thus removing the historic NOFILE limit to a UNIX process's open files), moved the poll(2) system call under the vnode framework, and did a lot of general clean-up work in the kernel.

I spent 7 years at AT&T, then left for a small start-up company just before AT&T created USL. I worked on file systems, writing one that transparently compressed and uncompressed files on the fly, and another that sped up system throughput and used an intent log for fast recovery. These were eventually ported to the SCO OpenServer V UNIX System. Then I developed stackable file systems for commercial UNIX systems. The file system business evolved into a file server business, and then the company was bought by EMC, where I still work as a manager of one of the file system groups. In total, I have about 20 years of UNIX programming experience, both kernel-level and user-level.

Since I was involved in the review of the first edition of APUE, Addison-Wesley contacted me for suggestions for candidates to update the book. I wanted the book to be updated properly, the way Rich would have wanted, and to honor his memory, so I volunteered for the project.

Why did you update APUE and how does the second edition of APUE differ from the first edition? Where did you have the most changes?

Rich's book is a classic, but the world has changed a lot since it was first published in 1992. Standards have evolved, UNIX system implementations have come and gone, and technology has advanced significantly. I added a chapter on sockets, two chapters on threads, and totally rewrote the chapter on communicating with a printer to reflect the technological advancement from a serial PostScript printer to a network-attached PostScript printer. I removed the chapter that dealt with modem communication, but I made it available on the book's Web site. Other than the printer chapter, Chapter 2 shows the most change. It deals with standards, and these have changed significantly over the past 13 years. One other major change is that I shifted the implementation focus from 4.3+BSD and SVR4 to more contemporary platforms: FreeBSD 5.2.1, Linux 2.4.22, Mac OS X 10.3, and Solaris 9. (The source code for the examples is also available on the book's Web site.)

Updating a Classic

The book is so big. Why is this so and how long did it take you to update it?

The first edition of APUE weighed in at 744 pages. (My first book was 784 pages long, but appeared much shorter because we used thinner stock.) The second edition is almost 200 pages longer than the first because of the new material added. Besides the new chapters, existing chapters cover new interfaces from the Single UNIX Specification, which has merged with POSIX.1 since the first edition was printed.

Initially, I spent six months learning to write with Rich's style and developing a couple sample chapters so that the Addison-Wesley reviewers could decide if I was the right candidate for the job. After I received the go-ahead, it took about two and a half years to complete the project.

Was it a fun process to update the book? What did you learn through the process?

The work was fun because the UNIX System provides an enjoyable, elegant programming paradigm, but it was also frustrating at times. There was a lot of material to cover, and every time I looked up from the computer, one of the four platforms I was using was releasing a newer version with added functionality. Most of my experience had been with System V, so I learned a lot about FreeBSD, Linux, and Mac OS X. I had to read a lot of BSD and Linux source code to understand how many of the system calls and libraries were implemented.

From your perspective, what's so special about the UNIX environment?

The UNIX environment is unequivocally the best operating system environment I've ever used. The abstractions are simple and elegant. Tools (commands designed to do one thing well) can be combined in new ways to solve various problems. Treating files as simple byte streams allow us to process files using common tools. For example, you don't need to build a search engine into every new program when you can run grep. In most cases where the file format isn't ASCII, you can run strings and pipe the output to grep to get what you need. Although some people find the command syntax too cryptic, I appreciate anything that reduces the amount of typing I have to do. Years ago I used one operating system where the commands were very long, like "remove-this-file-from-the-directory" instead of "rm." That level of verbosity resulted in a poorly designed interface.

The UNIX programming environment is especially elegant. Interfaces are well-thought out, and functionality is decomposed into the basic building blocks needed to accomplish a wide variety of tasks. One true test of how well something is designed is to see how easy it is to modify and extend without having it collapse under its own weight. The UNIX System has always been easy to enhance and extend to solve new problems without becoming unusable.

Putting It Together

What tools did you use to write the book?

I used vi to edit the files, make to manage the construction of each chapter, groff to typeset the pages, gpic to generate diagrams, gtbl to generate tables, grap to convert data into graphs, loom to insert source code into the book, refer to build the bibliography, and xghostview to preview finished pages. Many awk and shell scripts were used to assist in processing text. The index tools initially developed by Jon Bentley and Brian Kernighan were used to build the index. An interesting (to me, anyway) story surrounds the use of loom. Initially, I couldn't find this tool. It wasn't in the first edition's source material provided by Addison-Wesley. Nobody knew what it was or where it could be found. Internet search engines also failed to find it. (Apparently the search engine technology has since improved, because some can find it now.) Anyway, I had to reverse-engineer the tool from how the book materials used it. I built my own version from scratch. During the three-year period, my disk died, so I had to restore my system from backups. Unfortunately, I forgot to back up my loom source, so I had to reverse-engineer it a second time and write it all over again. There's at least one moral here.

What operating systems do you run at home?

In no particular order, SCO OpenServer 5, SCO UnixWare 7, Mandrake Linux 9.5, Mac OS X 10.3, Solaris 9, FreeBSD 5.2.1, Windows XP, Windows 2000, and Windows 95 (to support some legacy hardware, which I'm about to decommission).

Do you have any plans for new books?

I don't have any immediate plans at this time to write any more books. If I did, my wife would probably kill me. I worked on APUE2e during nights, weekends, and vacations, which took me away from my family. Now I need to spend some time with them.

How did Dilbert make it to the cover?

I've always been a fan of Scott Adams and his Dilbert comic strip. More often than not his humor is true to life. Several Dilberts have used UNIX as the punch line in a joke, so they seemed appropriate for the cover of a UNIX programming book. The Dilbert I originally wanted to use was thought to be too provocative, so I settled on one that was tamer.

Book Information

With the 2005 revision of Advanced Programming in the UNIX Environment, a new generation of UNIX programmers has an up-to-date guide to this elegant programming environment, complete with examples that work on contemporary systems such as FreeBSD, Linux, MacOS X, and Solaris.

Title:Advanced Programming in the UNIX Environment (2nd Edition)
Web link:http://www.apuebook.com
Publisher:Addison-Wesley Professional Computing Series
List Price:$74.99
Authors:W. Richard Stevens, Stephen A. Rago
Edition:Hardcover

About Steve Rago

Steve Rago is the author of UNIX System V Network Programming. Rago was one of the Bell Laboratories developers who built UNIX System V Release 4. He served as a reviewer for the first edition of Advanced Programming in the UNIX Environment. Rago currently works as a manager at EMC, specializing in file systems and file servers.

Copyright Jupitermedia Corp. All Rights Reserved.