Articles

Unix: A History and a Memoir

While I didn’t grow up with Unix, I used Unix throughout my academic and professional career. I first used SunOS Unix when I was a physics student at university. I’d grown up with MS-DOS and was already familiar with working from the command line. But the Unix command line was so much more powerful than MS-DOS. By stringing together a few commands, you can create new commands and custom shortcuts that make work easier. I love the power and flexibility of the Unix command line.

And so I was excited to discover a book by Brian Kernighan, about the origin and development of Unix at Bell Labs. You may recognize Kernighan’s name. He authored and co-authored many books about technology. My own bookshelf includes several of his works, such as The Unix Programming Environment (with Rob Pike), The AWK Programming Language (with Alfred Aho and Peter J. Weinberger), and The C Programming Language (with Dennis M. Ritchie). And now my bookshelf includes Kernighan’s latest entry, Unix: A History and a Memoir.

The book is a thrill to read. Unix: A History and a Memoir explores how Unix came about, and then how it developed, from the perspective of someone who was there. The book includes first-hand and related stories about Unix and many of the commands we take for granted today. I reached out to Brian Kernighan to ask him about his book. Thanks to Brian for his time in responding to the interview! Here are a few highlights from that engaging conversation:

JH: What prompted you to write this book?

BWK: I thought it would be nice to have a history of what happened at Bell Labs. Jon Gertner wrote a book The Idea Factory: Bell Labs and the Great Age of American Innovation that described the physical science work at Bell Labs. This was an authoritative work, very technical, but not something that I could do. But it was kind of the inspiration for this book. There’s also a book by James Gleick, The Information: A History, a Theory, a Flood, that isn’t specific to Bell Labs, but it’s very interesting. That was kind of an inspiration for this, too. I originally wanted to write an academic history of the Labs, but I realized I just couldn’t write an academic history about it. I figured it was better to write something based on my own memories and the memories of those who were there at the time. So that’s where the book came from.

JH: What are some stories in the book that you’d like people to read about?

BWK: I think there are really two stories I’d like people to know about, and both of them are origin myths. I heard them afresh about a year ago when Ken Thompson and I were at the Vintage Computer Festival about a year ago.

One is the origin of Unix itself. How Bonnie (Ken’s wife) went off on vacation for three weeks, just at the time that Ken thought he was about three weeks away from having a complete operating system. (Brian adds this was a consistent story, and Bonnie confirms it too.) This was, of course, due to Ken’s very competent programming abilities, and it was incredible he was able to pull it off. It was written entirely in Assembly, and was really amazing work. [This story starts on page 33 in the book. Ken was working on “a disk scheduling algorithm that would try to maximize throughput on any disk” but particularly the PDP-7’s very tall single-platter disk drive. In testing the algorithm, Ken said “I was three weeks from an operating system.” He broke it down to three things, which he wrote one per week: an editor, an assembly, and a kernel. And about that time, Bonnie was leaving for a three week vacation to take their son to visit Ken’s parents in California, so Ken had those three weeks to work undisturbed.]

And then there’s the origin story for grep. Over the years, I’d gotten the story slightly wrong. I thought Ken had written grep entirely on demand. [This story starts on page 70 in the book. Doug McIlroy had said “Wouldn’t it be great if we could look for things in files?” Ken said “Let me think about it overnight” and the next morning Ken showed Doug the grep command he’d written earlier.] It was classic Ken that he had a great idea, a neat idea, a clean idea – and he was able to write it very quickly. Regular expressions were already present in the text editor, so really he just pulled out regex from the editor and turned it into a program (grep).

JH: Memory was tight on the older machines, compared to what we run today. How did memory limitations drive Unix design?

BWK: Memory drove the design quite a bit. There wasn’t a lot of memory on the earlier systems we had. The first Unix system was on the PDP-7, and actual memory was like 8kb, or maybe 16kb. The PDP-11, when we started using them (the PDP-11/20 and PDP-11/45) had like 65kb of construction space and a similar amount of data space. You had to fit the operating system and the programs you were running into that limited memory. It was backed up by disk and at most 5MB of secondary storage, and DECtapes that were 100k storage.

Memory was very tight, and so we were always worried about it. The discipline was that you had to be very careful about what you were doing, you had to write very tight code. That drives an economy of design – you don’t just throw in things because it would be fun, you have to think about what you’re putting in there.

But it could lead to bad habits, too. Like how many things can you fit into 8 bits? troff fit a lot of stuff into a small amount of memory. And so you had fundamental limitations like “there will never be more than X of these things, so that’s X bits.” And encoding for things was decided on the first digit, things like that. It was forced on you by not having much space. [There’s a story at the bottom of page 105 in the book about troff code and how it was very tight.]

JH: I loved that you used groff to write the book. Why did you choose groff?

BWK: I guess you could say troff is the devil that I know. I did research in document preparation at the time. I wasn’t involved in troff but I did write my own formatter at university. It was all inspired by Salzer’s RUNOFF program. [Page 43 in the book mentions nroff. See also Chapter 5 starting at page 99.] I was intrigued by formatters. With Bill Plauger I started writing books [The Elements of Programming Style]. And people at the Labs were using troff to write patents. After Joe Ossanna died, I was left updating troff after that. [This story starts on page 105 in the book.]

I updated troff to support not just one output device, but to support other output devices. This was a problem because everything was coded very tightly. I was writing books, and others were writing technical papers. We were trying to emulate the format of professional journals, so we had macros for emulating the format of the American Physical Society’s Physical Review Letters journal.

We had eqn for mathematics and tbl for doing tables. This let us handle technical materials in a way that was new and different. I’ve seen some books that are riddled with errors because the program listings in them were mangled. So troff was the thing we used for books.

James Clark and others created groff, the open source version. They cleaned it up, and fixed a lot of the limitations of troff. It’s very satisfactory – not fabulous, it inherited some limitations from troff – but it’s great to use. You can put anything on the page that you like with groff. It’s sort of like a machine language for printing. There’s preprocessing for what goes in, and postprocessing for what goes after. They’re band-aids, but they are band-aids that let me do what I want.

JH: Who else from 1127 do you keep in touch with? When did you last get together?

BWK: I keep in touch with a lot of folks from the Labs. Sometimes it’s because of the book, and sometimes it’s other things. There was a 50th anniversary at the Lab in October, and that was the last time I was physically in contact with anyone. I trade emails with Jon Bentley. I’m working on a new book, and Jon is kind enough to help with comments. I keep in touch with Alfred Aho and Peter Weinberger. Peter is at Google now. And I trade emails with Bjarne Stroustrup. And Doug McIlroy, Rob Pike, Stu Feldman, Gerard Holzmann.

Gerald had a lot of great photos to put in the book. He’s sort of a pack rat on photos. There’s also a great website about The Unix Heritage Society. Warren Toomey runs it.

JH: What’s the next book or project you’re working on?

BWK: Ten years ago I wrote D is for Digital. And five years ago, I did another version of it called Understanding the Digital World published from the Princeton University Press. But an enormous number of things have happened even in the last five years, so I’m updating the book. I’m taking the Summer to write it, and the Fall to finish it. Jon Bentley has been very helpful. At just over 180 pages, Unix: A History and a Memoir is a fantastic read. If you are a fan of Linux, or any open source Unix, including the BSD versions, you will want to read this book.

Unix: A History and a Memoir is available on Amazon in paperback and e-book formats. Published by Kindle Direct Publishing, October 2019.

About the author

Jim Hall

Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder and project coordinator of FreeDOS. At work, Jim is CEO of Hallmentum, an IT executive consulting company that provides hands-on IT Leadership training, workshops, and coaching