◷ Computing history

Unix and the C language: the story that began at Bell Labs in 1969

How Ken Thompson and Dennis Ritchie created Unix and the C language at Bell Labs, why they spread everywhere and which of their ideas we still use daily.

Every time you open a terminal on a Linux server, a Mac or an Android smartphone, you are using something that descends directly from an operating system born almost by chance in 1969. Unix and the C language, created at Bell Labs by a small group of researchers, are among the most influential technologies in the history of computing. Many of their ideas are so widespread that we no longer notice them.

After Multics

In the 1960s Bell Labs was taking part, together with MIT and General Electric, in the development of Multics, an ambitious time-sharing operating system. The project was very complex and progressed slowly. In 1969 Bell Labs decided to withdraw.

Some of the researchers who had worked on it, including Ken Thompson and Dennis Ritchie, did not want to give up the interactive working environment Multics promised. Thompson found a little-used minicomputer, a PDP-7 from Digital Equipment Corporation, and began writing a simpler system on his own. The name Unix began as a pun on Multics, emphasising its simplicity.

From the PDP-7 to the PDP-11

The first version was written in assembly language. When the group obtained a more powerful PDP-11, the system was moved to the new machine and began to be used inside Bell Labs, initially also for preparing documents for the patent department. It was this practical use that justified buying the hardware.

The birth of C

Thompson had created a language called B, derived from BCPL, a language designed by Martin Richards. B, however, had no data types and fitted the PDP-11 poorly, since that machine worked with bytes and words of different sizes.

Between 1971 and 1973 Ritchie developed a successor, C, which added data types, structures and a memory model close to the hardware. C made it possible to write code almost as efficient as assembly, but far more readable and, above all, portable.

The decisive step

In 1973 the Unix kernel was rewritten in C. It was an unusual choice: at the time operating systems were written in assembly, because it was believed that only this way could the necessary performance be achieved. Writing Unix in C meant that, to move it to a new computer, it was largely enough to write a C compiler for that machine and adapt a small portion of hardware-dependent code.

The ideas of Unix

Unix stood out for a few simple, powerful ideas:

  • Everything is a file. Documents, devices and, in many cases, communication channels are read and written with the same operations.
  • A hierarchical file system, with nested directories and paths such as /usr/bin.
  • Small programs that do one thing and do it well.
  • Pipes, which connect the output of one program to the input of another.

Pipes

Pipes were introduced in 1973 at the insistence of Doug McIlroy, who had argued for years that programs should be connectable like garden hoses. The result is that complex tasks are achieved by combining simple tools:

grep " 404 " access.log | awk '{print $7}' | sort | uniq -c | sort -nr | head

On a web server log in the common format, this line shows which pages generated the most 404 errors by combining six different programs, none of which knows anything about the others. It is the Unix philosophy in practice.

Why it spread

There is also a legal reason. Because of a 1956 antitrust consent decree, AT&T, which owned Bell Labs, could not sell computing products. Unix was therefore licensed to research centres and academic institutions at very low cost, together with its source code. Thousands of students learned operating systems by studying and modifying the Unix code.

In Berkeley, California, an important variant was born, BSD, which among other things introduced one of the first widely used implementations of TCP/IP. When in the 1980s AT&T was finally able to sell Unix commercially, the world found itself with many different versions. To ensure compatibility between them, the POSIX standard was defined.

The K&R book

In 1978 Brian Kernighan and Dennis Ritchie published The C Programming Language, known as "K&R". For years the book was the de facto definition of the language, and it made famous the first example of every programming course:

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
    return 0;
}

C was standardised by ANSI in 1989 and by ISO shortly afterwards.

The legacy

In 1983 Thompson and Ritchie received the Turing Award. The legacy of Unix is everywhere: Linux, the BSD systems, macOS, Android and iOS descend from Unix or follow its model. C is still one of the most widely used languages for operating systems, firmware and embedded software, and its syntax influenced C++, Java, JavaScript, C# and many others.

In my daily work on servers and log analysis, the command line and pipes remain the fastest tools for answering a concrete question. It is remarkable proof of how solid those ideas are.

In short

  • Unix was born in 1969 at Bell Labs, after the withdrawal from the Multics project, through the work of Ken Thompson and Dennis Ritchie.
  • Ritchie developed the C language between 1971 and 1973; in 1973 the Unix kernel was rewritten in C, making it portable.
  • A hierarchical file system, "everything is a file", small programs and pipes are the key ideas of Unix.
  • Low-cost licences spread Unix through the research world; Linux, BSD, macOS and many other systems descend from it.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. With degrees in computer science and psychology, he combines technical analysis with an understanding of the human factor.

Read also