Small Tools, Not Small Libraries
The C philosophy is one of small tools doing one thing well. The difference between a small tool and a small library is twofold:
- A small tool has a larger overhead; it needs its own process with all the associated costs.
- A small tool is less flexible. Another program making use of it can invoke it (possibly with some command-line arguments) and then it can only be controlled by the standard input. This is not very flexible, and leads to problems.
Most often cited is the UNIX mv command. The designers of UNIX decided that the shell, rather than the application, should be responsible for expanding wildcards. This means that the program being invoked would have no way of knowing whether the arguments were originally a list of files or a wildcard. Imagine the following command line:
mv *.exe *.bin
If UNIX provided a library for wildcard expansion rather than making the shell do it, the mv command would know that you had given it two arguments and that you wanted to rename everything that ends with .exe to the same thing with a .bin extension. Under UNIX, however, this isn't the case. The mv command receives a list of files and tries to rename them all with the name of the last file.