Dennis Ritchie, the C Language and the Portability of Unix

Leggi questo articolo in italiano
Sticker 002 · One Sticker, One Story. View Dennis Ritchie’s card · Browse the Outstanding Programmers Sticker Album

Dennis Ritchie developed the C programming language at Bell Labs and helped create Unix with Ken Thompson. The two projects grew together. Unix needed a language that could express low-level system operations, and building the operating system put each of the language’s design choices to the test.

How the C programming language began

In the early 1970s, the Bell Labs team worked with machines that had very little memory. Writing a system meant controlling operations such as reading a character or accessing a memory address. Assembly gave programmers that control, but it tied much of their code to a particular processor family. Moving a program to a different computer could mean rewriting substantial parts of it.

Ritchie started from B, Ken Thompson’s language, which drew on BCPL. Ritchie introduced types such as int and char so the compiler could distinguish operations on integers from operations on characters. C retained direct access to memory through pointers. Programmers could express what their system code should do and leave many of the processor-specific instruction choices to the compiler. Read Ritchie’s account of how C developed.

Why Unix was rewritten in C

In 1973, much of the Unix kernel was rewritten in C. Think of a function that searches a sequence for a character. In assembly, the programmer specifies the machine’s registers and instructions. In C, the programmer can express the search as a loop and recompile the same function for a different machine. That saves adaptation work and makes it easier to share fixes.

An operating system still has to work with the hardware. Startup code, interrupts and device drivers can require machine-specific work. Unix showed how a team could confine those dependencies to particular parts of the system and carry much of the remaining code across to another architecture. In 1983, Ritchie and Thompson received the Turing Award for their work on operating systems, especially Unix. See Ritchie’s Computer History Museum profile.

Four lines from the original C compiler

In c00.c from the historical last1120c version, these calls register four reserved words in the compiler’s symbol table. The number next to each word is an internal identifier used in that version.

init("int", 0);
init("char", 1);
init("float", 2);
init("double", 3);

Excerpt from last1120c/c00.c, lines 44–47. Copyright 1972 Bell Telephone Laboratories, Inc. In his notes on the early compilers, Ritchie explains that this version predates the preprocessor, so many internal identifiers appear as literal numbers. An entry for long is still commented out in the same file. You can see the language taking shape in the source itself.

What free software inherited

C gave projects such as GCC and the Linux kernel a language suited to working close to the hardware while supporting multiple architectures. Each project’s licence determines how its code can be reused. Early Unix licensing varied by distribution and period. One way to explore that history is to compare the source of an early compiler with the source of a free software project today.

You can apply the same lesson to a small program. If you’re writing a tool that counts the characters in a file, keep the counting logic separate from the code that opens the file. That lets you test the logic with a sample string and reuse it when the input comes from somewhere else.

Nominate a programmer for the album

Know someone who made a contribution to software that readers can verify? Share their name, the project, what they contributed and at least one source. Contact details are optional and used for follow-up. You can also use the nomination form on the Roots page.

← Back

Thank you for your response. ✨

← Sticker 001 · Ken Thompson · Sticker 003 · Douglas McIlroy → · Browse all 24 stickers

Leave a comment

Your email address will not be published. Required fields are marked *