Update
This commit is contained in:
parent
390c8b8a4c
commit
3d11ef05d8
36 changed files with 2003 additions and 1984 deletions
|
@ -1,6 +1,6 @@
|
|||
# Unix Philosophy
|
||||
|
||||
Unix philosophy is one of the most important and essential approaches to [programming](programming.md) (and by extension all [technology](tech.md) design) which advocates great [minimalism](minimalism.md) and is best known by the saying that **a program should only do one thing and do it well**. Unix philosophy is a collective [wisdom](wisdom.md), a set of design recommendations evolved during the development of one of the earliest (and most historically important) [operating systems](os.md) called [Unix](unix.md), hence the name. Having been defined by [hackers](hacking.md) (the true, old style ones) the philosophy naturally advises for providing a set of many highly effective tools that can be combined in various ways, i.e. to perform [hacking](hacking.md), rather than being restricted by a fixed, intended functionality of huge do-it-all programs. Unix philosophy advocates [simplicity](kiss.md), clarity, modularity, reusability and composition of larger programs out of very small programs rather than designing huge monolithic programs as a whole. Unix philosophy, at least partially, lives on in many project and Unix-like operating systems such as [GNU](gnu.md)/[Linux](linux.md) (though GNU/Linux distros are more and more distancing from Unix), has been wholly adopted by groups such as [suckless](suckless.md) and [LRS](lrs.md) (us), and is even being reiterated in such projects as [plan9](plan9.md).
|
||||
Unix philosophy is one of the most important and significant software design philosophies, an approach to [programming](programming.md) (and by extension all [technology](tech.md) design) which advocates great [minimalism](minimalism.md) and is best known by the saying that **a program should only do one thing and do it well**. Unix philosophy is a collective [wisdom](wisdom.md), a set of design recommendations evolved during the development of one of the earliest (and most [historically](history.md) important) [operating systems](os.md) called [Unix](unix.md), hence the name. Having been defined by [hackers](hacking.md) (the true, old style ones) the philosophy naturally advises for providing a set of many highly effective tools that can be combined in various ways, i.e. to perform [hacking](hacking.md), rather than being restricted by a fixed, intended functionality of huge do-it-all programs. Unix philosophy advocates [simplicity](kiss.md), clarity, modularity, reusability and composition of larger programs out of very small programs rather than designing huge monolithic programs as a whole. Unix philosophy, at least partially, lives on in many project and Unix-like operating systems such as [GNU](gnu.md)/[Linux](linux.md) (though GNU/Linux distros are more and more distancing from Unix), has been wholly adopted by groups such as [suckless](suckless.md) and [LRS](lrs.md) (us), and is even being reiterated in such projects as [plan9](plan9.md).
|
||||
|
||||
NOTE: see also *[everything is a file](everything_is_a_file.md)*, another famous design principle of Unix -- this one is rather seen as a Unix-specific design choice rather than part of the general Unix philosophy itself, but it helps paint the whole picture.
|
||||
|
||||
|
@ -10,12 +10,12 @@ In 1978 [Douglas McIlroy](mcilroy.md) has written a short overview of the Unix s
|
|||
|
||||
1. **Each program should do one thing and do it well**. Overcomplicating existing programs isn't good; for new functionality create a new program.
|
||||
2. **Output of a program should be easy to interpret by another program**. In Unix programs are chained by so called [pipes](pipe.md) in which one program sends its output as an input to another, so a programmer should bear this in mind. [Interactive](interactive.md) programs should be avoided if possible. Make your program a [filter](filter.md) if possible, as that exactly helps this case.
|
||||
3. **Program so that you can test early, don't be afraid to throw away code and rewrite it from scratch**.
|
||||
3. **Program so that you can test early, don't be afraid to throw away code and start anew**.
|
||||
4. **Write and use tools**, even if they're [short-lived](throwaway_script.md), they're better than manual work. Unix-like systems are known for their high [scriptability](script.md).
|
||||
|
||||
This has later been condensed into: do one thing well, write programs to work together, make programs communicate via text streams, a universal interface.
|
||||
|
||||
Details about to what extent/extreme this minimalism ("doing only one thing") should be taken are of course a hot topic of countless debates and opinions, the original Unix hackers are often highly strict, famous example of which is the "cat -v considered [harmful](harmful.md)" presentation bashing a relatively simple function added to the [cat](cat.md) program that should only ever concatenate files. Some tolerate adding a few convenience functions to trivial programs, especially [nowadays](modern.md).
|
||||
Exactly to what extent/extreme this minimalism ("doing only one thing") should be taken is, of course, a subject of countless debates and opinions, the original Unix hackers are often highly strict, famous example of which is the "cat -v considered [harmful](harmful.md)" presentation bashing a relatively simple function added to the [cat](cat.md) program that should only ever concatenate files. Some tolerate adding a few convenience functions to trivial programs, especially [nowadays](modern.md).
|
||||
|
||||
**Simple example**: likely the most common practical example that can be given is [piping](pipe.md) small [command line](cli.md) utility programs; inside a Unix system there live a number of small programs that do *only one thing but do it well*, for example the [`cat`](cat.md) program that only concatenates and outputs the content of selected files, the [`grep`](grep.md) program that searches for patterns in text etc. In command line we may use so called [pipes](pipe.md) to chain some of these simple programs into more complex processing [pipelines](pipeline.md) by redirecting one program's output stream to another one's input. Let's say we want to for example automatically list all first and second level headings on given webpage and write them out alphabetically sorted. We can do it with a command such as this one:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue