Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?

Advanced Programming in the UNIX Env, 2nd Ed. 128

Eater writes "W. Richard Stevens wrote Advanced Programming in the UNIX Environment, which was published in 1993 by Addison-Wesley. It quickly became the cornerstone of many bookshelves. The original edition has been revised by Stephen A. Rago to more accurately reflect the current landscape of UNIX and UNIX-like systems. APUE is targeted at the experienced C programmer with a working knowledge of UNIX. It includes chapter long examples of real-world applications, and--as with other works by W. Richard Stevens -- somehow manages to serve simultaneously as an enlightening tutorial and a valuable reference book." Read on for the rest of Eater's review of the book's recent second edition.
Advanced Programming in the UNIX Environment, 2nd Ed.
author W. Richard Stevens, Stephen A. Rago
pages 927
publisher Addison-Wesley
rating 9
reviewer Eater
ISBN 0201433079
summary Essential classic for experienced C progammers working in UNIX environments

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 Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Advanced Programming in the UNIX Env, 2nd Ed.

Comments Filter:
  • by cerberusss ( 660701 ) on Tuesday July 12, 2005 @03:42PM (#13046878) Homepage Journal
    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?
    • by HyperChicken ( 794660 ) * on Tuesday July 12, 2005 @03:46PM (#13046949)
      Donald Knuth? Created his own typesetting language. Can't get much more "do it yourself" than that.
      • by Timesprout ( 579035 ) on Tuesday July 12, 2005 @03:55PM (#13047064)
        Big deal, I have several trees growing in my garden from seed, which I intend to gnaw down with my own teeth before turning the wood into pulp for paper on which I will hand write every copy of my forthcoming autobiography 'Sprout from the veggie patch'. This sure to be a classic will of course be hand delivered by me and I will be available 24/7 to read it aloud for the visually impaired, or anyone purchasing the audio version.
        • I have several trees growing in my garden from seed, which I intend to gnaw down with my own teeth
          Sorry, but I represent the Beavers of North America, and you are being served with a Cease and Desist for copying our prior art and patents.

          The Department of Homeland Security has also been informed that you are in possession of terrorist devices, namely augmented dentition, which you could only have obtained if you were gene-spliced.

          As someone who has defied and defiled creation through this gene-splicing, your name and location has also been handed over to the new ultra-secret, government-funded Fundamentalists for Human Purity, who will quickly show you the error of your ways during your upcoming "vacation".

          Also, after running your words through Echelon, we have determined that "trees ... gnaw down" is code for "Bush ... knock off", or a threat to assassinate the president. Your room at Gitmo is being prepared even as you read this.

        • by Anonymous Coward
          "Big deal, I have several trees growing in my garden from seed, which I intend to gnaw down with my own teeth"

          Wow, you must be one real eager beaver.

          Thank you. I will be here all week.
        • Yeah, well I have an iron mine in my backyard. I'm refining the ore into steal, and then making a saw from that to cut down my trees, also growing in the backyard.

          Now if I could just write a book worthy of the effort.

      • Fuh, that's nothing. I know an author who built his own paper mill.
    • Where can you find people nowadays that have time to learn how to do proper layout, typesetting, graphics and indexing as well as knowing all that's necessary to write a book? Division of labour is a good thing.
    • by BYTEBuG ( 630830 ) on Tuesday July 12, 2005 @04:12PM (#13047269)
      8 years ago I was developing a UDP-based distributed messaging system for our local intranet, and got to a point where I couldn't get things working right. I had been using Stevens' books as my references, and I noticed his email address in the preface.

      "What the hey," I thought. "I'll email him." So I did, and then went to lunch.

      Imagine my surprise upon my return when I saw 2 return emails waiting! He explained in great detail what I was doing wrong conceptually, and gave exacting instructions on how to make a certain part work. In the second email, he said it didn't sit well with him to leave me with an "unoptimal solution" (his words), so on his own time he came up with an even better paradigm, and sent actual tested code to implement it!

      What can I say? His books will always grace my shelf.
    • As a production manager, I would dread having to troubleshoot something like that. On the other hand, I wouldn't mind it if the author had to troubleshoot it himself . . . I look at open-source typesetting programs a lot, and while I like the idea, I'm bewildered by how I could keep a book on schedule the way I can with Quark or InDesign in a coding language. The Troff website is a little obtuse at the moment, but I wouldn't mind learning more.
    • In the Cafe jaro...they give it a Way, and then right out the door.
    • I think the Pragmatic Programmers [] do just that.
    • by Tom Christiansen ( 54829 ) <> on Tuesday July 12, 2005 @06:07PM (#13048496) Homepage
      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?
      Amongst other things, Richard wrote quite the elaborate but easy-to-use troff macro set to aid in the production of those books.

      You're right: that level of pride in workmanship is nearly (but not quite) unheard of in modern technical publishing. But can a publisher ever really measure up to the exacting standards of the most extreme of precise-minded (aka anal) authors? Probably not. That sort of author is apt to be seen as more than half-mad and too much of a hassle for the publisher to try to work with. "After all," says the publisher, "it's just a book." "Sure, but it's my book!" carps back the meticulous author.

      You asked where one can find such people. The best living example of fastidious attention to detail that springs to mind is Jeffrey Friedl, as seen in his 500-page arcane tome, Mastering Regular Expressions [], now it its second edition. If I recall correctly, Jeffrey did the typesetting, indexing, etc, which means that he was his own production team. This is nearly universally deemed far more trouble than it's worth, but at least you'll have no one to complain about if, for example, the index doesn't measure up--which it seldom if ever does.

      Check out Jeffrey's index [] for MRE (it's in PDF format). Give it a glance. Notice the richness, the usefulness. Notice the multiple levels of headings, rather than just two. Notice the careful treatment of fonts and of the ordering of analphabetic symbols. Many another gem is hidden within that index, which you'll notice if you skim it a bit.

      This sort of quality you will never, ever get from some freelance, paid-by-the-hour indexer who doesn't know the problem space, who won't have their name on that book's cover. It does make a difference.

      Whoops. We now return you from this unintentional pæan to MRE's production quality.

      On Richard Stevens, he was a marvelous and wonderful human being, and he is missed, not just by me, but by many.


      • "the ordering of analphabetic symbols"

        Did you go to a English public school?

        • You probably should have looked up the term online before posting such a mean-spirited comment.

          Analphabetic is a word and it has many meanings:

          1. an illiterate person who does not know the alphabet

          1. not alphabetic; "an analphabetic arrangement of letters"; "Jesperson's system of phonetic transcription is analphabetic"
          2. unlettered having little acquaintance with writing; "special tutorials to assist the unlettered sector of society"
          3. relating to or expressed by a writing system that is not
      • by IvyMike ( 178408 ) on Wednesday July 13, 2005 @02:31AM (#13051194)
        Check out Jeffrey's index for MRE (it's in PDF format). Give it a glance. Notice the richness, the usefulness. Notice the multiple levels of headings, rather than just two. Notice the careful treatment of fonts and of the ordering of analphabetic symbols. Many another gem is hidden within that index, which you'll notice if you skim it a bit.

        This sort of quality you will never, ever get from some freelance, paid-by-the-hour indexer who doesn't know the problem space, who won't have their name on that book's cover. It does make a difference.

        For an offtopic, fictional, and non-serious counter-argument, find a copy of Cat's Cradle by Kurt Vonnegut and read Chapter 55, "Never Index Your Own Book." [] (you'll have to scroll down with the link I provided, sorry.)

        I'm giving the link because it's so weirdly applicable; how often do I get to reference a passage about authors who self-index? Back in reality, I agree with Tom: Friedl's book and index are perfect.
  • I don't mean to sound like a troll, but I already have a few similar books in my dusty collection... so what's new in this one that can't be found in the other books and/or web sites out there? anything exciting enough for me to put on pants and drive down to my Books-a-Million?
  • by xactuary ( 746078 ) on Tuesday July 12, 2005 @03:42PM (#13046882)
    It quickly became the cornerstone of many bookshelves.

    Um, those books never get read - used as they are in making space for shelving to hold the other books!
    • Advanced Programming in the UNIX Env, 2nd Ed.

      Bah! Whatever happened to RTFManPages.

      Um, those books never get read - used as they are in making space for shelving to hold the other books!

      Sure they do - how else are you going to get the "real deal", the background, the culture, the arcana, that separates you from the (m)asses? And that also lets you grok the whys of something as opposed to just the hows.

      Great justification for sitting on the can for an hour at the office any day.

  • I fear that this new edition might not be as good as the original just because its not Stevens. Stevens is one of my Heroes of the Comp Sci world, and I pray that his soul is doing well in heaven. I'll just wait until my other friends tell me that the coast is clear
    • Couldn't have put it better my self. I haven't done any system programming in a while, but this book is indespensible for anyone who has a working knowledge of C and is interested in learning some good system programming.

      Don't let the name fool you, no previous system programming experience required.
  • troff/groff? (Score:4, Interesting)

    by Amoeba Protozoa ( 15911 ) <<jordan.husney> <at> <>> on Tuesday July 12, 2005 @03:49PM (#13046988) Homepage
    I remember reading that all the Stevens books were typeset with troff. I wonder if this new edition has been typset the same way?

  • Back in the day I did a lot of programming against specific operation system API such as Windows and UNIX and had the classic books for each environment. Now that programming environments such as Java and C# exist most of those book just gathering dust. How the UNIX API changed that much since 1993? I have huge book on Win32, MFC and UNIX programming that today are just take up space.
    • It's not as if Java and C# are the only languages anyone's developing in anymore.

      While many applications can be written for Java and C# or LAMP, or one of many other "platform indepedent" development environments, there are many types of applications that absolutely cannot be because they need access to OS-level or hardware-level APIs.
    • Another way of looking at this... with so such content available on the Internet for free is there a real value in buying books that document APIs? I've noticed that most of the books that I buy today are about software development methologies i.e. TDD, Agile, re-factoring etc. I tend to go to the Internet for find the answers to implementing detail and view APIs.
      • by Chemical Serenity ( 1324 ) on Tuesday July 12, 2005 @08:17PM (#13049529) Homepage Journal
        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.
    • by typical ( 886006 )
      Back in the day I did a lot of programming against specific operation system API such as Windows and UNIX and had the classic books for each environment. Now that programming environments such as Java and C# exist most of those book just gathering dust.

      [minor irritation]

      Yes. You are (according to your webpage) an Eclipse developer. This means that you would not be likely to run into OS-specific things any more than a Win32 developer would care about the details of how named pipes are handled on Unix.
    • Professionally I'm Java developer but in my spare time I create computer languages primality in C++. My main argument is that large book that document APIs seems to be dated since nearly all of that material is available on the web. As I mentioned, I have a lot of UNIX, Win32 and Java books but I find myself using the Internet more then those books.

      I'll give you an example, I bought a book on pthreads when I prototyping a virtual machine design. The book was about 2 years old and the examples in the boo

  • programming in the *nix environment, new as in nill, the review neglects to mention how well people with a basic understanding of C with an interest in programming the platform will interpret or even benefit from this book.

    Bieng one of these people, would I benefit more from Stevens book than this title?
    Or would this one make a better selection?
    Should both of them grace my bookshelf?
    • Well, since this is a rewrite with some new additions of the Stevens title, either will work. As for your case, I'd say yes, buy one. The original Stevens was amazing- it explained how to use a Posix OS from the basics of file operations through networking and concurrency. If you haven't ever done systems level programming on Unix, this is THE place to start.
    • 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.
  • Table of contents (Score:2, Insightful)

    by systems ( 764012 )
    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.

  • I've got "Internetworking with TCP/IP Vol. 3 (Sockets)" that I picked up in a used bookstore for a dollar. It was written in '93 and deals with 4.3BSD - all the code examples are in K&R-style C and the API's are old, but the algorithms are there and the advice on design is very relevant.

    It's a really good book. My first network-aware programs were written using this book. There's examples for several different protocols and a deep discussion of Sun RPC. Concurrency takes a couple of chapters and id
    • The "Internetworking With TCP/IP" series was written by Douglas Comer, not Richard Stevens.

      Stevens wrote the "TCP/IP Illustrated" series and the "UNIX Network Programming" series, along with such other titles as "Advanced Programming in the UNIX Environment".
    • The dude sure wrote a couple of good books. Even as references they were very usefull. Now how should I interpret the return for recv() again? /me runs of to his bookshelf
    • UNIX Network Programming is an absolute must-have for anyone who wants to learn network coding. It explains everything you need to know for both clients and servers, discusses the various threading and forking models servers use, covers pthreads, and touches on lots of other essential subjects.

      Later in the book Stevens goes on to explain the protocols in depth, developing ping and traceroute clients using raw sockets. With help from this chapter I successfully scared the crap out of a nearby friend by blas
  • by photon317 ( 208409 ) on Tuesday July 12, 2005 @04:08PM (#13047211)
    Stevens' books are always great, and this one is no exception. I use this book regularly and I highly recommend it. But that aside, there is another shorter and somewhat overlapping book: Advanced Unix Programming: 2nd Edition [] by Marc J. Rockhind, that I highly recommend anyone who might like the reviewed Stevens book should check out as well. Link was the only reference to it that I saw, but my copy is softcover, whereas the link appears to be hardcover.
  • by Indomitus ( 578 ) on Tuesday July 12, 2005 @04:15PM (#13047303) Homepage Journal
    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.
    • The people who are buying the book for its contents, not its cover, will buy it anway; and the people who would normally buy "Learn UNIX in 21 seconds" will buy it, and perhaps actually end up learning something worthwhile for a change! :)
  • At least he was to me, the one time I met him at a Usenix conference, where he autographed one of his books for me.

    His books were tops in the field. Glad to hear the revised edition is still good.
  • I'd recently read Eric Raymond's The Art of Unix Programming and having particularly enjoyed his "case studies" where he'd describe the rationale behind a file format or protocol I was looking for a book that would go into this both wider in subject area and deeper in explanation.

    A friend recommended to me the book the Advanced Unix book, and I actually saw this book last week while browsing but was hesitant to purchase it. First because the Dilbert comic strip on the front made me wary that the content w

  • by mrm677 ( 456727 ) on Tuesday July 12, 2005 @04:37PM (#13047584)
    As a graduate student, I really needed the original APUE book at one time but was put off by the $80 asking price (or something like that). Meanwhile, all of my Indian classmates brought their "Indian" editions with them which they acquired for insanely cheap prices. The difference is that these were often paperback and definitely were denoted as a special edition for India, but the content was the same. Very discouraging for me at the time because I had no way to acquire a discounted edition.

    • Yes. I bought this book in India, but I paid more along the lines of $10. It's a good idea to buy a lot of these books when you go to India. The content is the same just the paper quality is a tad different and is softcover. The book prices here are completly ridiculous.
    • An Indian coworker of mine years ago would come back from his India visits with armloads of cheap computer books. $20 is on the mark.

      Besides being paperback, the quality of the binding and product overall was definitely substandard. Under heavy use, I'd expect the $80 hardcover to easily withstand more than 4x the abuse.

      But what I really really want is a frigging PDF version of this book. I'd pay $50 for it. Hear me, publishers? Think of the profits!

  • Advanced Unix Programming came out with a 2nd edition in 2004, and I was lucky enough to spot it in a Half Price Books [] here in Indy. This is very similar, in terms of upgraded content.

    In particular, the test systems are the same between books. (FreeBSD, Linux, Solaris, Darwin.) Both books have grown considerably to take on the growth of Unix and the various flavors.

    Of course, AUP came out in 1985, so it had a little more turf to cover.

    For those not familiar with AUP, it is a slightly different beast from

  • the "Modem Dialer" example from the first edition has been removed

    According to the book's official site, the modem chapter was pulled from the print edition, but it was still revised, and is available as a PDF or Postscript file.

    (The site is chock full of frames, but here's the inner content page [] talking about it and linking to the chapter's files.)
  • by Embedded Geek ( 532893 ) on Tuesday July 12, 2005 @05:59PM (#13048414) Homepage
    Years ago I dreamt up and championed a UNIX System Programming extension class through Cal State, Fullerton. It took tons of work to develop the class, to get the department to market it, and and then finally offer it. It was a dream come true. I used Stevens APUE as the primary text.

    About three weeks into it, though, I realized I was struggling. My lectures were flat and the class really wasn't getting much out of it. I asked Paul Banks, a student who'd taken several courses with me, what I was doing wrong. "You're reading your slides, Kevin. You're not interacting with the subject matter like you usually do."

    I realized that, basically, I was intimidated as Hell by Stevens' mastery of the subject. I changed my approach. The next lecture, when there was something I couldn't entirely wrap my brain around, I tried something different. I stepped away from the lectern, sat down in the chair at the front of the class and admitted my ignorance. "I don't have direct experience on this. This is how I think this thing works. Is that how you guys read it?" Sure enough, someone in the class indicated that they'd touched on the issue in their code, but had been confused. The class came alive as my lecture became a discussion, which is my preferred mode of teaching.

    Looking back, I guess I owe that success to Stevens as much as the problem (and, yes, the problem was really between my ears, thank you very much...). His books have always been about experimentation as a means of understanding, not dictating down lessons down to the reader. If only I'd taken that tack when I started the class I could have saved myself much trouble. I'm just glad I corrected my approach and that everyone got a lot out of that class.

    Paul passed away a few years ago and I was glad that I had made a point of thanking him profusely for his advice. My only regret about the class is that I never did the same to Stevens for APUE.

  • Steven's APUE and Unix Network Programming are the books that turned me from a novice into someone who felt confident enough to pursue programming for a career. The first edition of APUE is so extremely well written - clear, concise and lucid. I'm definitely going to flick through the new edition, but the great thing is that the first one is still reelveant, in fact it's one of the five books I take with me to any new job.

    • I picked up the 2nd Ed while on a trip to NYC. My initial reading of it suggest that the new author has worked pretty hard to closely emulate Stevens' style and keep as much of his original material intact as possible. The new section on threads for example reads as though it could have been written by the man himself.

      (BTW what a useless review - quoting the blurb and the preface. Slashdot often does better... )

  • Having had both editions of Unix network programming (gives me one to lend out...)

    Glad it has been updated, it seems superficially dated which might put people off, although there is actually lots of stuff thats still completely valid.
  • I can see Solaris and Linux, but FreeBSD and OSX? What about AIX and HP-UX? There are surely many more developers working on AIX and HP-UX than FreeBSD and OSX combined unless you just count PHP web-heads.
    • Re:Platforms? (Score:1, Informative)

      by Anonymous Coward
      PHP web-heads tend to hang out on Linux more than anything else.

      OS X has tons of developers. It has 10% of the desktop market share. It has developers.
  • I just bought the first ed last quarter for my Unix programming class, now I am going to have to go out and buy another ed just so I don't have something quite so freaking historic on my bookshelf.

Natural laws have no pity.