The Unix Philosophy
In A Nutshell
Write small programs to do one thing, and do it well.
Write programs that work together.
Read input and write output as human-readable text, because that is the universal interface.
Origins
The Unix philosophy originated with Ken Thompson as a set of approaches to software development based on the experiences that he had in leading the developers of the Unix operating system. The philosophy emphasizes building short, simple, clear, modular, and extendable code that can be easily maintained and re-purposed by others.
“This is the Unix philosophy: Write programs that do one thing and do it well. Write programs that work together. Write programs that handle text streams, because that is a universal interface.”
–Doug McIlroy
Eric Raymond's 17 Unix Rules
Rule of Modularity: Developers should build a program out of simple parts connected by well defined interfaces, so problems are local, and parts of the program can be replaced in future versions to support new features. This rule aims to save time on debugging code that is complex, long, and unreadable.
Rule of Clarity: Developers should write programs as if the most important communication is to the developer, including him- or herself, who will read and maintain the program rather than the computer. This rule aims to make code readable and comprehensible for whomever works on the code in future.
Rule of Robustness: Developers should design robust programs by designing for transparency and discoverability, because code that is easy to understand is easier to stress test for unexpected conditions that may not be foreseeable in complex programs. This rule aims to help developers build robust, reliable products.
Rule of Representation: Developers should choose to make data more complicated rather than the procedural logic of the program when faced with the choice, because it is easier for humans to understand complex data compared with complex logic. This rule aims to make programs more readable for any developer working on the project, which allows the program to be maintained.
Rule of Extensibility: Developers should design for the future by making their protocols extensible, allowing for easy plugins without modification to the program's architecture by other developers, noting the version of the program, and more. This rule aims to extend the lifespan and enhance the utility of the code the developer writes.
Worse Is Better
Richard P. Gabriel suggests that a key advantage of Unix was that it embodied a design philosophy he termed “worse is better”, in which simplicity of both the interface and the implementation are more important than any other attributes of the system—including correctness, consistency, and completeness.
See Also