Наши партнеры

Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

Eric Steven Raymond

Thyrsus Enterprises


This book and its on-line version are distributed under the terms of the Creative Commons Attribution-NoDerivs 1.0 license, with the additional proviso that the right to publish it on paper for sale or other for-profit use is reserved to Pearson Education, Inc. A reference copy of this license may be found at http://creativecommons.org/licenses/by-nd/1.0/legalcode.

AIX, AS/400, DB/2, OS/2, System/360, MVS, VM/CMS, and IBM PC are trademarks of IBM. Alpha, DEC, VAX, HP-UX, PDP, TOPS-10, TOPS-20, VMS, and VT-100 are trademarks of Compaq. Amiga and AmigaOS are trademarks of Amiga, Inc. Apple, Macintosh, MacOS, Newton, OpenDoc, and OpenStep are trademarks of Apple Computers, Inc. ClearCase is a trademark of Rational Software, Inc. Ethernet is a trademark of 3COM, Inc. Excel, MS-DOS, Microsoft Windows and PowerPoint are trademarks of Microsoft, Inc. Java. J2EE, JavaScript, NeWS, and Solaris are trademarks of Sun Microsystems. SPARC is a trademark of SPARC international. Informix is a trademark of Informix software. Itanium is a trademark of Intel. Linux is a trademark of Linus Torvalds. Netscape is a trademark of AOL. PDF and PostScript are trademarks of Adobe, Inc. UNIX is a trademark of The Open Group.

The photograph of Ken and Dennis in Chapter═2 appears courtesy of Bell Labs/Lucent Technologies.

The epigraph on the Portability chapter is from the Bell System Technical Journal, v57 #6 part 2 (July-Aug. 1978) pp. 2021-2048 and is reproduced with the permission of Bell Labs/Lucent Technologies.

Revision History
Revision 0.955 August 2003esr
Proofreading complete.
Revision 0.9431 July 2003esr
Incorporates proofreader fixes.
Revision 0.9329 July 2003esr
More minor corrections and typo fixes.
Revision 0.9221 July 2003esr
Minor corrections and typo fixes.
Revision 0.9117 July 2003esr
Factual correction about VM/CMS; a bit more about C++.
Revision 0.9114 July 2003esr
Reformat displays to fit 70-character width.
Revision 0.907 July 2003esr
Freeze for production.
Revision 0.8730 June 2003esr
Kirk McKusick contributed a summation of the BSD lawsuit.
Revision 0.8626 June 2003esr
Cleanup release.
Revision 0.8524 June 2003esr
Review and cameos from Ken Thompson.
Revision 0.8417 June 2003esr
Final stuff from Steve Johnson. Fold in 0.83 copy edits.
Revision 0.8315 June 2003esr
Minor changes from work on Teaching Guide. Be systematic about compactness versus semi-compactness.
Revision 0.8211 June 2003esr
Steve Johnson's contributions.
Revision 0.816 June 2003esr
Cross-reference and attribution markup fixes.
Revision 0.805 June 2003esr
Merged in Chapter 7-20 copy edits.
Revision 0.7430 May 2003esr
Merged in Chapter 1-6 copy edits.
Revision 0.7328 May 2003esr
Added discussion of Plan 9 in the Futures chapter.
Revision 0.7226 May 2003esr
Minor fixes.
Revision 0.7119 May 2003esr
Cathy is up to Chapter 5, Henry Spencer to Chapter 11.
Revision 0.7017 May 2003esr
Two new diagrams in Contrasts and Complexity. Rob Landley's review pass is done. Contributions by Stuart Feldman and Mike Lesk. Bibliography has been consistency-checked.
Revision 0.6712 May 2003esr
WWW is an example of New Jersey thinking applied to hypertext. Revisions to Languages chapter.
Revision 0.6611 May 2003esr
Cameo quote from Brian Kernighan. Various minor corrections.
Revision 0.659 May 2003esr
New section on `Worse is Better' in the compexity chapter. Henry Spencer's review pass is up to Chapter 8.
Revision 0.648 May 2003esr
Folded in suggestions from Brian Kernighan.
Revision 0.637 May 2003esr
Typo fixes. Fold in Chapter 1 through 8 comments from Ken Arnold,
Revision 0.621 May 2003esr
Fold in Chapter 1 and 2 comments from Henry Spencer.
Revision 0.6129 Apr 2003esr
Added reference for claim about DARPA valuing BSD open source in History chapter. Minor corrections to Complexity chapter.
Revision 0.6028 Apr 2003esr
Regexp discussion moves to Minilanguages; Yacc and Lex moved to Tools. Added case study on statistical spam filtering. More on strategies for reducing latency in the Optimization chapter.
Revision 0.5825 Apr 2003esr
End of second editing pass.
Revision 0.5721 Apr 2003esr
Replaced httpget case study with blq. Folded in review comments and quotes by David Korn.
Revision 0.5620 Apr 2003esr
Fold in Ken Arnold's comments. New section (inspired by Doug McIlroy) in the Modularity chapter, "Compactness and the strong single center".
Revision 0.5517 Apr 2003esr
Slim down the Context section. Some corrections to C history from dmr. Quotes from Keith Packard and Jim Gettys. OpenOffice.org uses zip(1), not gzip(1). More on the Rule of Extensibility.
Revision 0.5410 Apr 2003esr
Better description of common vs. def-ref linkage in C. Incorporated Doug McIlroy's second round of comments. Added case study of VM/CMS to Contrasts.
Revision 0.537 Apr 2003esr
Note on the Javs CLASSPATH problem. URLs are derivative of Unix filenames. Scotch an urban legend about C's ++. Added case study of Wily and more analysis to the Complexity chapter.
Revision 0.523 Apr 2003esr
Correction from Dennis Ritchie for the Portability epigraph. Various typo fixes.
Revision 0.512 Apr 2003esr
Dates and attributions for most of the epigraphs added. Typo fixes.
Revision 0.52 Apr 2003esr
New chapter on Complexity, after Interface; expands on and replaces the Tools chapter discussion of whether Emacs is an argument against the Unix philosophy. Fetchmail as a study in why pipelines aren't enough. SVr4 IPC is obsolete, but it turns out SVr4 shared memory is not.
Revision 0.4630 Mar 2003esr
Folded in advice and quotes from Doug McIlroy.
Revision 0.4518 Mar 2003esr
More typo fixes. Note that documentation-format problems are on their way to being solved at the user-presentation level by "everything is HTML, every reference is a URL". Substantially rewritten and expanded material on user environment variables. More on the implicit sociology of version-control systems. Chapters on Transparency and Multiprogramming swapped.
Revision 0.4411 Mar 2003esr
More on multitasking in the Contrasts chapter. Many typo fixes.
Revision 0.436 Mar 2003esr
Added MVS case study to Contrasts chapter. "No junk, no confusion." in the Modularity chapter. New section on the pros and cons of compression in Textuality.
Revision 0.4212 February 2003esr
Add fcntl/ioctl to things Unix got wrong.
Revision 0.4111 February 2003esr
Corrections and additions to MacOS case study. A bit more about binary files as caches. Added cite of Butler Lampson. Additions to history chapter. Note in futures chapter about C and exceptions. Many typo fixes.
Revision 0.45 February 2003esr
Release for public review.
Revision 0.322 January 2003esr
First eighteen-chapter draft. Manuscript walkthrough at Chapter 12. Limited release for early reviewers.
Revision 0.22 January 2003esr
First manuscript walkthrough at Chapter 7. Released to Dmitry Kirsanov at AW production.
Revision 0.116 November 2002esr
First DocBook draft, fifteen chapters. Languages rewritten to incorporate lots of feedback. Transparency, Modularity, Multiprogramming, Configuration, Interfaces, Documentation, and Open Source chapters released. Shipped to Mark Taub at AW.
Revision 0.01999esr
Public HTML draft, first four chapters only.

To Ken Thompson and Dennis Ritchie, because you inspired me.

Table of Contents

Who Should Read This Book
How to Use This Book
Related References
Conventions Used in This Book
Our Case Studies
Author's Acknowledgements
I. Context
1. Philosophy
Culture? What Culture?
The Durability of Unix
The Case against Learning Unix Culture
What Unix Gets Wrong
What Unix Gets Right
Open-Source Software
Cross-Platform Portability and Open Standards
The Internet and the World Wide Web
The Open-Source Community
Flexibility All the Way Down
Unix Is Fun to Hack
The Lessons of Unix Can Be Applied Elsewhere
Basics of the Unix Philosophy
Rule of Modularity: Write simple parts connected by clean interfaces.
Rule of Clarity: Clarity is better than cleverness.
Rule of Composition: Design programs to be connected with other programs.
Rule of Separation: Separate policy from mechanism; separate interfaces from engines.
Rule of Simplicity: Design for simplicity; add complexity only where you must.
Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do.
Rule of Transparency: Design for visibility to make inspection and debugging easier.
Rule of Robustness: Robustness is the child of═transparency and simplicity.
Rule of Representation: Fold knowledge into data, so═program logic can be stupid and robust.
Rule of Least Surprise: In interface design, always do the═least surprising thing.
Rule of Silence: When a program has nothing surprising to say, it should say nothing.
Rule of Repair: Repair what you can — but when you must fail, fail noisily and as soon as possible.
Rule of Economy: Programmer time is expensive; conserve it in preference to machine time.
Rule of Generation: Avoid hand-hacking; write programs to write programs when you can.
Rule of Optimization: Prototype before polishing. Get it working before you optimize it.
Rule of Diversity: Distrust all claims for one true way.
Rule of Extensibility: Design for the future, because it will be here sooner than you think.
The Unix Philosophy in One Lesson
Applying the Unix Philosophy
Attitude Matters Too
2. History
Origins and History of Unix, 1969-1995
Genesis: 1969–1971
Exodus: 1971–1980
TCP/IP and the Unix Wars: 1980-1990
Blows against the Empire: 1991-1995
Origins and History of the Hackers, 1961-1995
At Play in the Groves of Academe: 1961-1980
Internet Fusion and the Free Software Movement: 1981-1991
Linux and the Pragmatist Reaction: 1991-1998
The Open-Source Movement: 1998 and Onward
The Lessons of Unix History
3. Contrasts
The Elements of Operating-System Style
What Is the Operating System's Unifying Idea?
Multitasking Capability
Cooperating Processes
Internal Boundaries
File Attributes and Record Structures
Binary File Formats
Preferred User Interface Style
Intended Audience
Entry Barriers to Development
Operating-System Comparisons
Windows NT
What Goes Around, Comes Around
II. Design
4. Modularity
Encapsulation and Optimal Module Size
Compactness and Orthogonality
The SPOT Rule
Compactness and the Strong Single Center
The Value of Detachment
Software Is a Many-Layered Thing
Top-Down versus Bottom-Up
Glue Layers
Case Study: C Considered as Thin Glue
Case Study: GIMP Plugins
Unix and Object-Oriented Languages
Coding for Modularity
5. Textuality
The Importance of Being Textual
Case Study: Unix Password File Format
Case Study: .newsrc Format
Case Study: The PNG Graphics File Format
Data File Metaformats
DSV Style
RFC 822 Format
Cookie-Jar Format
Record-Jar Format
Windows INI Format
Unix Textual File Format Conventions
The Pros and Cons of File Compression
Application Protocol Design
Case Study: SMTP, a Simple Socket Protocol
Case Study: POP3, the Post Office Protocol
Case Study: IMAP, the Internet Message Access Protocol
Application Protocol Metaformats
The Classical Internet Application Metaprotocol
HTTP as a Universal Application Protocol
BEEP: Blocks Extensible Exchange Protocol
XML-RPC, SOAP, and Jabber
6. Transparency
Studying Cases
Case Study: audacity
Case Study: fetchmail's -v option
Case Study: GCC
Case Study: kmail
Case Study: SNG
Case Study: The Terminfo Database
Case Study: Freeciv Data Files
Designing for Transparency and Discoverability
The Zen of Transparency
Coding for Transparency and Discoverability
Transparency and Avoiding Overprotectiveness
Transparency and Editable Representations
Transparency, Fault Diagnosis, and Fault Recovery
Designing for Maintainability
7. Multiprogramming
Separating Complexity Control from Performance Tuning
Taxonomy of Unix IPC Methods
Handing off Tasks to Specialist Programs
Pipes, Redirection, and Filters
Security Wrappers and Bernstein Chaining
Slave Processes
Peer-to-Peer Inter-Process Communication
Problems and Methods to Avoid
Obsolescent Unix IPC Methods
Remote Procedure Calls
Threads — Threat or Menace?
Process Partitioning at the Design Level
8. Minilanguages
Understanding the Taxonomy of Languages
Applying Minilanguages
Case Study: sng
Case Study: Regular Expressions
Case Study: Glade
Case Study: m4
Case Study: XSLT
Case Study: The Documenter's Workbench Tools
Case Study: fetchmail Run-Control Syntax
Case Study: awk
Case Study: PostScript
Case Study: bc and dc
Case Study: Emacs Lisp
Case Study: JavaScript
Designing Minilanguages
Choosing the Right Complexity Level
Extending and Embedding Languages
Writing a Custom Grammar
Macros — Beware!
Language or Application Protocol?
9. Generation
Data-Driven Programming
Case Study: ascii
Case Study: Statistical Spam Filtering
Case Study: Metaclass Hacking in fetchmailconf
Ad-hoc Code Generation
Case Study: Generating Code for the ascii Displays
Case Study: Generating HTML Code for a Tabular List
10. Configuration
What Should Be Configurable?
Where Configurations Live
Run-Control Files
Case Study: The .netrc File
Portability to Other Operating Systems
Environment Variables
System Environment Variables
User Environment Variables
When to Use Environment Variables
Portability to Other Operating Systems
Command-Line Options
The -a to -z of Command-Line Options
Portability to Other Operating Systems
How to Choose among the Methods
Case Study: fetchmail
Case Study: The XFree86 Server
On Breaking These Rules
11. Interfaces
Applying the Rule of Least Surprise
History of Interface Design on Unix
Evaluating Interface Designs
Tradeoffs between CLI and Visual Interfaces
Case Study: Two Ways to Write a Calculator Program
Transparency, Expressiveness, and Configurability
Unix Interface Design Patterns
The Filter Pattern
The Cantrip Pattern
The Source Pattern
The Sink Pattern
The Compiler Pattern
The ed pattern
The Roguelike Pattern
The ‘Separated Engine and Interface’ Pattern
The CLI Server Pattern
Language-Based Interface Patterns
Applying Unix Interface-Design Patterns
The Polyvalent-Program Pattern
The Web Browser as a Universal Front End
Silence Is Golden
12. Optimization
Don't Just Do Something, Stand There!
Measure before Optimizing
Nonlocality Considered Harmful
Throughput vs. Latency
Batching Operations
Overlapping Operations
Caching Operation Results
13. Complexity
Speaking of Complexity
The Three Sources of Complexity
Tradeoffs between Interface and Implementation Complexity
Essential, Optional, and Accidental Complexity
Mapping Complexity
When Simplicity Is Not Enough
A Tale of Five Editors
The Right Size for an Editor
Identifying the Complexity Problems
Compromise Doesn't Work
Is Emacs an Argument against the Unix Tradition?
The Right Size of Software
III. Implementation
14. Languages
Unix's Cornucopia of Languages
Why Not C?
Interpreted Languages and Mixed Strategies
Language Evaluations
Emacs Lisp
Trends for the Future
Choosing an X Toolkit
15. Tools
A Developer-Friendly Operating System
Choosing an Editor
Useful Things to Know about vi
Useful Things to Know about Emacs
The Antireligious Choice: Using Both
Special-Purpose Code Generators
yacc and lex
Case Study: Glade
make: Automating Your Recipes
Basic Theory of make
make in Non-C/C++ Development
Utility Productions
Generating Makefiles
Version-Control Systems
Why Version Control?
Version Control by Hand
Automated Version Control
Unix Tools for Version Control
Runtime Debugging
Combining Tools with Emacs
Emacs and make
Emacs and Runtime Debugging
Emacs and Version Control
Emacs and Profiling
Like an IDE, Only Better
16. Reuse
The Tale of J. Random Newbie
Transparency as the Key to Reuse
From Reuse to Open Source
The Best Things in Life Are Open
Where to Look?
Issues in Using Open-Source Software
Licensing Issues
What Qualifies as Open Source
Standard Open-Source Licenses
When You Need a Lawyer
IV. Community
17. Portability
Evolution of C
Early History of C
C Standards
Unix Standards
Standards and the Unix Wars
The Ghost at the Victory Banquet
Unix Standards in the Open-Source World
IETF and the RFC Standards Process
Specifications as DNA, Code as RNA
Programming for Portability
Portability and Choice of Language
Avoiding System Dependencies
Tools for Portability
Portability, Open Standards, and Open Source
18. Documentation
Documentation Concepts
The Unix Style
The Large-Document Bias
Cultural Style
The Zoo of Unix Documentation Formats
troff and the Documenter's Workbench Tools
The Present Chaos and a Possible Way Out
Document Type Definitions
Other DTDs
The DocBook Toolchain
Migration Tools
Editing Tools
Related Standards and Practices
XML-DocBook References
Best Practices for Writing Unix Documentation
19. Open Source
Unix and Open Source
Best Practices for Working with Open-Source Developers
Good Patching Practice
Good Project- and Archive-Naming Practice
Good Development Practice
Good Distribution-Making Practice
Good Communication Practice
The Logic of Licenses: How to Pick One
Why You Should Use a Standard License
Varieties of Open-Source Licensing
MIT or X Consortium License
BSD Classic License
Artistic License
General Public License
Mozilla Public License
20. Futures
Essence and Accident in Unix Tradition
Plan 9: The Way the Future Was
Problems in the Design of Unix
A Unix File Is Just a Big Bag of Bytes
Unix Support for GUIs Is Weak
File Deletion Is Forever
Unix Assumes a Static File System
The Design of Job Control Was Badly Botched
The Unix API Doesn't Use Exceptions
ioctl2 and fcntl2 Are an Embarrassment
The Unix Security Model May Be Too Primitive
Unix Has Too Many Different Kinds of Names
File Systems Might Be Considered Harmful
Towards a Global Internet Address Space
Problems in the Environment of Unix
Problems in the Culture of Unix
Reasons to Believe
A. Glossary of Abbreviations
B. References
C. Contributors
D. Rootless Root
Editor's Introduction
Master Foo and the Ten Thousand Lines
Master Foo and the Script Kiddie
Master Foo Discourses on the Two Paths
Master Foo and the Methodologist
Master Foo Discourses on the Graphical User Interface
Master Foo and the Unix Zealot
Master Foo Discourses on the Unix-Nature
Master Foo and the End User