The UNIX Philosophy in 2019

+

UNIX Presentation

Earlier this week, I did a presentation for WWITPRO that detailed the UNIX philosophy and its relevance today. Given the subject matter, I decided to do the presentation in PostScript on my SPARCbook running Sun Solaris 2.5.1. This blog post details the content of the presentation for posterity!

What is UNIX?

Simply put, UNIX is an operating system that was created by Ken Thompson in 1969 that was rewritten shortly thereafter in Dennis Ritchie’s C programming language.

Both Thompson and Ritchie worked for AT&T Bell Labs at the time, which couldn’t participate on the software market due to tensions with the federal trade commission (AT&T was a monopoly in many markets at the time). So AT&T sold the source code for UNIX off to different companies, which modified it to suit their needs, thus creating their own flavor of UNIX.

AT&T also gave a copy of the UNIX source code to the University of California at Berkeley, who created the BSD flavor of UNIX that gained a lot of traction with other companies, who in turn modified BSD UNIX into their own unique flavor. UNIX flavors based on the original AT&T source code are collectively called the AT&T UNIX family while UNIX flavors based on BSD are referred to as the BSD UNIX family.

The Linux operating system we see frequently today was derived from the Free Software Foundation’s GNU project, which aimed to create an open source UNIX. Since Linux is functionally an open source UNIX operating system, most people use UNIX and Linux interchangeably.

To learn more about UNIX, refer to my Ultimate UNIX Timeline post.

What is the UNIX philosophy?

If you ask the average person working in a computer-related field what UNIX is, they’ll likely mention the word simplicity. Of course, it’s true that UNIX’s simple, elegant, modular design has resulted in a system that is easily extensible and powerful - but is this really a philosophy?

The UNIX philosophy is somewhat difficult to define, partly because it has changed over time to reflect certain virtues of UNIX that emerged during its evolution:

  • Collaborative development
  • Simple, portable, and programmer-focused
  • Focus on networking

The first known version of the UNIX philosophy was written by Ken Thompson in 1973:

  1. Write programs that do one thing and do it well
  2. Write programs to work together
  3. Write programs that handle text streams, because that is a universal interface

By the late 1970s, UNIX had spread like wildfire and evolved tremendously as a result. In 1980, Thompson and Ritchie summarized the major features of UNIX as follows:

  • A hierarchical file system incorporating demountable volumes
  • Compatible file, device, and inter-process I/O
  • The ability to initiate asynchronous processes
  • System command language selectable on a per-user basis
  • Over 100 subsystems including a dozen languages
  • High degree of portability

This led Brian Kernighan (who contributed to UNIX at AT&T alongside Thompson and Ritchie) to expand the UNIX philosophy during the 1980s:

  1. Everything is a file
  2. Small, single-purpose programs (modularity)
  3. Ability to chain programs together to perform complex tasks (piping)
  4. Avoid captive user interfaces - most UNIX programs are non-interactive (requiring arguments instead of user input) which makes them useful within scripts
  5. Configuration data stored in text

It’s also important to note that, by the 1980s, UNIX’s popularity was widely attributed to its simplicity compared to other software systems at the time. David Tilbrook at the University of Toronto put it plainly: “The one thing that has to be stated about UNIX is that it wasn’t a great advance in computing; if anything, it was a great simplification. It put into the realm of the user those things that were just inconceivable prior to that.”

SUN

The 1980s also saw the rise of many different UNIX workstation vendors, which relied on computer networks to transfer information and distribute computing tasks. In 1984, John Gage from Sun Microsystems (one of the first UNIX vendors) expanded the UNIX philosophy to include the importance of the network: “The network is the computer.”

When AT&T bought a chunk of Sun Microsystem in 1987 and announced that Sun OS 5 would be based on the AT&T UNIX family and not the BSD UNIX family, it shook up the UNIX community because Sun was the most aggressive/successful UNIX vendor. Other UNIX vendors formed the Open Software Foundation (OSF) to combat the AT&T/Sun partnership. During this turbulent time, two more events took place that would end up shaping the future of UNIX:

  • Linux (an open source UNIX equivalent) was released
  • A BSD legal battle led to BSD UNIX officially becoming open source (which in turn led to FreeBSD and NetBSD)

In short, by the early 1990s, it was quite clear that regardless of what UNIX vendors wanted, the future of UNIX was tied to open source software development. And this open source focus required a revision of the UNIX philosophy, which was promptly provided by Eric S. Raymond:

  1. Modularity: Write simple parts connected by clean interfaces (no complex, unreadable code)
  2. Clarity: Clarity is better than cleverness (others must work on the code)
  3. Composition: Design smaller programs that can be connected with other programs (avoid complex monolithic programs)
  4. Separation: Let policies be changed without destabilizing mechanisms (consequently reducing the number of bugs)
  5. Simplicity: Design for simplicity; add complexity only when you must
  6. Transparency: Design for visibility to make inspection and debugging easier
  7. Failure: When you must fail, fail noisily and ASAP
  8. Diversity: Distrust all claims for “one true way”
  9. Extensibility: Design for the future, because it will be here sooner than you think
  10. Parsimony: Write small, easily-replaceable code that can be thrown away if needed. Don’t be afraid to throw away large chunks of code if it sucks.

The open source revolution was still in its infancy during the late 1990s, and received a lot of backlash from closed source software companies, such as Microsoft. As a result, the UNIX philosophy was widely regarded as an outdated guideline during the early 2000s (even though Eric S. Raymond’s points were key to any software project at the time).

The perception at the time was that the UNIX philosophy:

  • Didn’t scale well to large projects
  • Wasn’t as good as a monolithic approach for many types of software
  • Was difficult to secure
  • Didn’t allow for easy creation of user interfaces

Of course, these perceptions were completely false, and the following decade would go on to prove that the UNIX philosophy of making open, simple, modular, scriptable systems was the best approach to all software.

Today, Linux and open source rules the world, and the UNIX philosophy is widely considered compulsory. Organizations are striving to build small, focused applications that work collaboratively in a cloud and microservices environment. We rely on the network, as well as HTTP (text) APIs for storing and referencing data. Moreover, nearly all configuration is stored and communicated using text (e.g. YAML, JSON or XML). And while the UNIX philosophy has changed dramatically over the past 5 decades, it hasn’t strayed too far from Ken Thompson’s original definition in 1973:

  • We write programs that do one thing and do it well
  • We write programs to work together
  • And we write programs that handle text streams, because that is a universal interface