Advanced Programming in the UNIX Env, 2nd Ed.
Few technical authors have had such a great impact on the geek community as Rich Stevens, and because of this, any review of his books should include a few words about the man himself.
Stevens' work typically tops any "recommended reading" list when it comes to TCP/IP networking or UNIX programming. Stevens passed away on September 1st, 1999. In addition to APUE, he authored UNIX Network Programming (Volume 1: APIs and Volume 2: IPC) and TCP/IP Illustrated (Volume 1: Protocols, Volume 2: Implementation, and Volume 3: TCP/T, HTTP, NNTP, Unix Domain Protocols.) Stevens was posthumously awarded the USENIX Lifetime Achievement Award for his extraordinarily lucid teaching and generous spirit within the community, which was accepted on his behalf by his surviving wife and children. (Slashdot coverage of his unfortunate death is available.)
Stephen A. Rago, who has taken on the daunting task of revising Stevens' APUE, worked at Bell Laboratories as a UNIX SVR4 developer. His first contact with Rich Stevens was an e-mail regarding a typographical error in Stevens' first book, UNIX Network Programming. Stevens later acted as a technical reviewer for Rago's UNIX System V Network Programming. Rago reciprocated as a technical reviewer for the first edition of APUE, and has done a fine job of revising that same text for the new second edition.
After more than a decade of changes in UNIX and UNIX-like operating systems, the original edition of APUE holds up well. Rago's revision reflects the following:
- System V variants are being replaced by Linux, Solaris being the last of these with any reasonable market share.
- 4.4BSD was the last UNIX release officially maintained by Berkeley's CSRG, with subsequent derivatives being maintained by volunteers.
- The popularity of Linux and inexpensive x86 hardware has introduced a notable shift in development.
- Apple Computer has abandoned its previous operating system for one based on Mach and FreeBSD.
- The original book was based on the 1990 version of the POSIX.1 standard. The new edition has incorporated changes from the 2001 version.
- Chapters on threads and thread control have been added.
- Some material has been omitted to reflect changes in common hardware. For example, the "Modem Dialer" example from the first edition has been removed, and "Communicating with a PostScript Printer" (which focused on serial and parallel communication) has been replaced with "Communicating with a Network Printer".
The following platforms were used in Rago's edition:
- FreeBSD 5.2.1 on Intel Pentium
- Linux 2.4.22 (Mandrake 9.2) on Intel Pentium
- Solaris 9 on 64-bit UltraSPARC IIi
- Darwin 7.4.0 (Mac OS X, version 10.3) on PowerPC
A comparison of the tables of contents between the first and second editions indicates only minor organizational changes. When delving into the text, it's apparent that Rago has done a painstaking job of reworking the text to reflect the changes over the past 13 years.
Notably, Rago has included a few new helpful tables in the chapter on UNIX standardization. These tables compare the differences among the four platforms he used in writing this edition, making this text rather valuable for those trying to support multiple offerings.
An entirely new part of this edition is two chapters dealing with POSIX threads. Rago presents this material first with an introductory chapter on threads, POSIX.1 primitives available for creating and destroying threads, and a discussion of the fundamental issues when dealing with synchronization between threads. The follow-up chapter is on thread control, dealing with the specifics of synchronization, reentrancy, and thread interaction with process-oriented system calls.
Stevens believed that the best way to learn code was to read code, and his books reflect that philosophy well. The original edition contained a chapter titled "Communicating with a PostScript Printer" that included a complete program to communicate over a RS-232 serial connection to an attached printer. Most PostScript printers today are accessed via a network interface, and Rago has managed to rewrite the material reflecting this while still maintaining the original intent of the chapter. The first edition's chapter on modem communication has been omitted from the new edition, but is still available via the book's website.
This book is no superficial rewrite of the first edition. From cover to cover, it's apparent that Rago has carefully interpreted the original text and rewritten it to accurately reflect the changes of the past 13 years; he has also managed to preserve to original lucid and efficient presentation style of Stevens' classic.
The book's official website is available here, including all source-code examples and errata.
You can purchase Advanced Programming in the UNIX Environment, 2nd Ed. from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
What I always liked about Stevens, is that he delivered print-ready copy to his publisher. This guy did everything himself. Layout, typesetting, graphics, indexing, the whole works. Where can you find people like that nowadays who take so much pride in their product that they hand-hold it from draft to customer?
8 of 13 people found this answer helpful. Did you?
I'd highly recommend it, even if you don't do a lot of C programming. For instance, big chunks of Python's os module are thin wrappers around POSIX systems calls. By knowing how those calls work at a low level, you'll be better able to leverage them in your Python code.
Ita erat quando hic adveni.
haven't read the book or anything, but i get the impression that it's mostly about user-space system-level programs. A lot of this is not really affected by the exact kernel version. Although I guess a lot of 2.6-specific stuff like udev and whatnot might be affected.
In a way though, the distribution and the way the filesystem is organized is more important than the particular kernel.
The first thing I like to check in a new book is the table of contents, yet the book homepage doesn't seem to have it.
I hate it when they do that, I'll have to look for it in the publisher 's website.
While I have no hard numbers to back this statement up, I would venture to guess that there are many people out there still using the 2.4 series kernel, just as there were many using 2.2 at this point in the 2.4 release series. In fact, there are probably a handful of people still using 2.2 and a very small number still on 2.0.
Not everyone can afford to be on the cutting edge.
Free as in speech, free as in beer, or free as in lunch?
Are they really going to put a Dilbert cartoon on the cover? It's a funny one but the original book has kind of a classic, authoritative look to it. Putting a comic strip on the cover makes it look more like one of those jokey 'Unix in 3 hours!' books.
You say "similar" books... do you mean that you already have the first edition, or that you don't have any of Steven's other books? (If you did have any of his books, but not the first edition of this one, you already know what "can't be found in the other books").
I'll assume you mean you haven't yet read any of his books - beleive me, they're worth it. When I first took an interest in TCP/IP, I passed over his "TCP/IP Illustrated" series for a lot of reasons - they were expensive, there were THREE of them (!), they were out-of-date, they weren't specific to my target environment, etc. I bought some of the other, less expensive alternatives, never learned much that I couldn't learn from reading RFC's, and was finally loaned a copy of "TCP/IP Illustrated, Volume 1". I was blown away by the quality of the book, and the quality of the writing. I've never read such a well-written technical book in my life, and I suspect I never will again. Nobody can clarify like Stevens. He goes through the details (all the details), but still keeps the book interesting.
I have to clear book purchases with my wife these days (sigh...) but this is one of the books on my wish list. I'll admit I've never read "Advanced Programming in the Unix Environment", but I guarantee that if it was written by W. Richard Stevens, it makes all other books written on the subject useless.
Now, on the other hand, I have to take this reviewers word that this new guy can write as clearly and as interestingly as Stevens, and so will you.
Because you can't spell "slaughter" without "laughter"
Are a lot of people still using the 2.4 series?
Yes. It's a known quantity and is extremely stable. 2.6 may be the latest and greatest, but it's still coming up with reports of some nasty performance problems under certain kinds of load.
Enterprise shops won't dare take risks with new OS releases. They'll sit until they have to move, either through obsolescence or (less likely) due to a new must-have feature.
If you're going to do systems level programming in Unix, this book is a must! Whether or not you would benefit from it elsewise depends on how much the frameworks you use insulate you from the gory details of libc and system calls.
Don't blame me, I didn't vote for either of them!
The reason dead tree still sells is that there is a great deal of convenience to having all the pertinent answers in one spot. Additionally, with Stevens work, the answers are not only pertinent but with analysis that is deep and insightful, with copious examples that are invariably correct, and usually represent the best way (or ways, with analysis as to which form is superior based on what it is you're trying to accomplish) to do the task.
Dry, unadorned documentation about APIs give no suggestions as to best implementation, or often where to look or what to try when things go wrong. Sure, you can look at other coders' code (if you can find something akin to what you're trying to accomplish), but it's obviously a sub-optimal solution.
Online knowledge is great, don't get me wrong... but when you have the masters of the art willing to author a condense tome filled to the brim with best practices accumulated over a lifetime of projects, it's worth shelling out some clams to have that handy. APUE, UNP (1+2) and TCPIP Illustrated (1,2,3) have saved my sanity on many an occasion, and I suspect they'll do so again.
"People will pay big bucks for the luxury of ignorance."