|
|
Subscribe / Log in / New account

Two views of the Unix philosophy

We have recently received two books, both of which attempt to set down the Unix philosophy. This philosophy is said to underlie the work we all do with Linux, so discussions of it are worth a look. Maybe we can finally find out what we have been trying to do all these years. [TAOUP cover]

The first is The Art of Unix Programming by Eric Raymond (published by Addison Wesley). We have discussed this book before on these pages, so a detailed look is not necessary at this time. Suffice to say that Eric's book is now available in the stores. It is also available on the net under a relatively restrictive Creative Commons license. [LATUP cover]

The other entry is Linux and the Unix Philosophy by Mike Gancarz, published by Digital Press. This book appears to be a fairly straightforward remake of Mr. Gancarz's The Unix Philosophy, published in 1994. References to Linux have been retrofitted in, but the book is little changed. If the underlying Unix philosophy is as enduring as these books would have us believe, a book from 1994 should still be current now. Unfortunately, Linux and the Unix Philosophy looks old; consider, for example, the author's advice that a function's parameter list should fit on a single line of an (80-column) screen. That might have been good advice for an old-style C function, but, in the modern world, where parameter names and types all go together, even a very short parameter list can take multiple lines.

This book also ignores many of the features of modern Unix/Linux programming, including scripting languages (beyond the shell) and graphical interfaces. In Mr. Gancarz's view, all programs are small, and their functions are minimal; he even states that multi-column output has bloated the ls command excessively. Or consider:

Why has the metric of MIPS become such a hot issue in the computer world today? Because as Unix usage has become more prevalent, the use of small programs has proliferated as well. Small programs, although they usurp little system memory when executing, derive the most benefit from the injection of additional CPU horsepower.

This discussion does not fit your editor's world, where the best way to improve the performance of a system is often to add memory.

The most interesting area of investigation, however, would be how the two books characterize the Unix philosophy. Happily, both of them provide nice sets of rules suitable for slides in any executive briefing - or a summary table in LWN. So, without further ado...

The Art of Unix Programming Linux and the Unix Philosophy
Write a big program only when it is clear by demonstration that nothing else will do. Small is beautiful.
Design for simplicity; add complexity only where you must. Make each program do one thing well.
Prototype before polishing. Get it working before you optimize it. Build a prototype as soon as possible.
(No rule, but portability is listed as one of the things Unix got right). Chose portability over efficiency.
Design programs to be connected with other programs. Store data in flat text files.
Make every program a filter
Avoid hand-hacking; write programs to write programs when you can. Use software leverage to your advantage. [i.e. reuse code].
Programmer time is expensive; conserve it in preference to machine time. Use shell scripts to increase leverage and portability.
In interface design, always do the least surprising thing. Avoid captive user interfaces.
When a program has nothing to say, it should say nothing. Silence is Golden
Look for the 90-percent solution.
Worse is better.
Design for visibility to make inspection and debugging easier.
Fold knowledge into data so program logic can be stupid and robust.
Repair what you can, but when you must fail, fail noisily and as soon as possible.
Separate policy from mechanism; separate interfaces from engines.
Distrust all claims for the "one true way."

The further expression of these rules shows the relative age and limited scope of Gancarz's book. He talks about flat text files, while Raymond discusses the importance of transparent, textual network protocols as well. Raymond covers the network, modern languages, and the ups and downs of programming techniques as an integral part of his book; Gancarz has a brief "Brave New World" chapter at the end where he treats bleeding-edge technologies like the Internet, artificial intelligence, object-oriented programming, and Java.

On the other side, Eric Raymond's tendencies are well known. The Art of Unix Programming can be verbose and gives a lot of coverage to Mr. Raymond's own work and beliefs. Most people would have found a way to write a Unix book without including quotes from famous people on the evils of gun control, for example.

Both books neglect areas of great concern for any contemporary software developer. Neither will give as much help as the implementer of a web browser, office suite, or DVD player might like. No developer can afford to be unaware of security issues in the current environment, but neither author devotes any space to security. What is the Unix philosophy's approach to security? Silence in response to that question is all too telling.

In the end, if your editor had to choose between the two books, he would go with The Art of Unix Programming, though both have their merits. Readers of either would be well advised to heed Mr. Raymond's last rule, however: distrust anybody who claims to know the "one true way."


to post comments

yeh, old news

Posted Oct 16, 2003 1:12 UTC (Thu) by coriordan (guest, #7544) [Link] (3 responses)

Design is important, but the unique thing about GNU/Linux, the thing that has brought the UNIX world back, reincarnated, has been the GNU philosophy.

So I'd like to mention a book who's release didn't become an LWN.net article: Free Software: Free Society, collected essays of Richard Stallman

The essays from this book, and many others are available in the philosophy section of the GNU website.

oh yeah, and about the article

Posted Oct 16, 2003 4:10 UTC (Thu) by coriordan (guest, #7544) [Link] (2 responses)

Good review.

I don't think I'd buy either book. "The Practice of Programming" is not bad, on mildly similar lines. But really, in my humble experience, if you want to learn about how to design an app, look at the design & code of a similar existing app, and read the mailing list archives to find out what decisions were contraversial, or what they regretted, etc.

oh yeah, and about the article

Posted Oct 16, 2003 11:34 UTC (Thu) by hppnq (guest, #14462) [Link] (1 responses)

"The Practice of Programming" is actually about programming, not about design like ESR's "The Art of Unix programming". ;-)

W.Richard Stevens wrote everything one might like to know about Unix programming, of course!

oh yeah, and about the article

Posted Oct 23, 2003 15:57 UTC (Thu) by Baylink (guest, #755) [Link]

RIP, Mr. Stevens.

ESR is a lightning rod, and while it didn't surprise me that Ciaran had
the first comment here, I'm really a bit surprised that there weren't
more...

While Ciaran likes to dis ESR whenever possible -- and some of those
snipes are actually well taken -- I will in fact agree wholeheartedly
with his primary thesis on this point: yeah, with a little help from
Linux, rms *did* change the world.

I firmly believe that the reason for the mad proliferation of Linux
(sorry; luv ya rms, but I'm not gonna play the terminology game) is in
fact the fact that rms has provided the GPL for Linus to choose to
license his kernel under. And there seems no realistic doubt that Our
Plans For World Domination (a phrase I don't see *near* often enough
anymore -- are we too close to think it's funny now?) will succeed beyond
our wildest dreams.

The only prediction I *can't* make, with any reasonable facility, is when
Microsoft Linux will ship.

:-)

Preview taoup online

Posted Oct 16, 2003 9:17 UTC (Thu) by larryr (guest, #4030) [Link]

The Art of Unix Programming is online at http://catb.org/~esr/writings/taoup/html/


Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds