August 17, 2021

What is the unix philosophy?

 

Instead of a common myth Unix is not about pipes or the kernel but it is a programming style created around the C language. The idea is to create software with the high level C language instead of using assembly language. This allows to writer larger programs which will need lots of RAM and disc space.
Some examples for typical Unix programs are gnuplot which has 150k lines of code in C and lyx which contains of 350k lines of code in C++. Both programs have a long tradition, are typical Unix programs and they are fulfilling lots of requirements.
There is a difference between writing a small piece of software in Assembly language which runs on a home computer and writing a larger program whcih is running on a mainframe computer. The obvious difference is, that a program like gnuplot can't be created by a single person in a weekend but it is long term effort done by a programmer's team.
Perhaps it sounds a bit unusual to ask, but why exactly are larger programs needed? Wouldn't it be ok to paint a chart with a software which needs only 100kb for the sourcecode? This has to do with the unix philosophy. The idea behind Unix is to write large scale programs which are fulling requirements from the end user. The typical program written in C has lots of parameters. It is not because the program itself is so complex but because the task which is textprocessing, graphics drawing or whatever is so complicated. The assumption is, that it is not possible to rewrite the gnuplot software in assembly language and compress it into 10k lines of code. Such a program would be run much faster, but it won't provide all the features of the original gnuplot software.
It is not a coincidence that 90% of the unix software is written in C/C++. Because this programming was designed for creating large programs. In contrast to Assembly language it wasn't invented for hardware needs, but C/C++ is a programmer friendly language. It supports functions, variables, and structs. The result is, that the programmers can write software which has lots of lines of code. Let us take a look what the typical Linux user will see after the first installation of a distribution. He will see that the operating system has occupied many gigabytes of his harddrive. In case of Debian a default installation will need 15 GB. And if the user installs additional software the requirement is much higher.
Somebody has written all the code in the past. This was done by Unix programmers who are familiar with the C language. They have created software packages for database management, text processing, image manipulation, mathematics needs and of course for networking demands. Programming itself is easy, but these applications are hard. A basic tutorial for the c language will fit on a single sheet of paper. C consists only if-then-statements, function declaration and some case switches. But programming a concrete application is very different from programming itself.