April 17, 1998
Interview with Brian Kernighan
Unix has, I think for many years, had a reputation as being difficult to learn and incomplete....But, as a program development environment, it's very easy to build a lot of these things. It's sort of like a kit. And if you want a new thing, you can take the pieces out of the kit and assemble them to make your new thing, rather more rapidly than you would be able to do the same thing in some other kind of environment. So, [when asked] "Does it do X?" [we would say] "No, but it's real easy. Do you want one by tomorrow? I'll give you one by tomorrow."
Brian Kernighan saw Unix as more than simply an operating system; to him, it was an entirely new way of viewing computers and programming. Although he claims he did not invent the notion of software tools, the idea was prominent throughout all of his work at Bell Labs, from creating eqn, to writing tutorials and manuals for all aspects of Unix and C, to developing a clean and efficient model of programming in The Elements of Programming Style. For Kernighan, the greatest strength of Unix lies in its flexibility.
Kernighan's work began in 1966 at MIT, ostensibly with the Multics project. However, he reports that he did little or no actual work on the output side of Multics. Instead, his work was primarily concerned with the CTSS system, and had very little to do with Multics specifically. He began working at Bell Labs over the summers of 1967 and 1968, while he was a graduate student at Princeton. He was not involved with Multics at Bell Labs, either; instead, he studied storage allocation algorithms under Doug McIlroy and graph partitioning under Shen Lin. Eventually, he wrote his Ph.D. thesis on graph partitioning, although he did not care for the subject very much. He began to work at the Labs on a permanent basis in February of 1969, and continued working on graph partitioning and combinatorial problems. As Thompson and Ritchie began to develop Unix, Kernighan quickly became involved; he was assigned user ID #9 on the main system, although he is not sure what brought him to the project so early.
His first significant work in Unix was writing eqn with Lorinda Cherry around 1973. He was actually inspired by his work as a grad student for Recording for the Blind; he would read math and science materials, and realized there was a natural way to orally communicate mathematical symbols and equations. Thus, his goal in writing eqn was to develop a similar means of communicating mathematical information to the text formatter. Eqn was the first program written to work "on top" of a text formatter; independently, it was not capable of much, but when used in conjunction with troff or a similar program, it could greatly broaden the printing and formatting abilities.
It was around the time of eqn that the notion of Unix as a toolkit began to develop among the programmers. Although Kernighan is reluctant to take credit for the idea of software tools, he concedes that he may have coined the phrase, as McIlroy claims. The notion of pipes, although closely related to software tools, may have come about as an independent idea, according to Kernighan. He states that the concept of pipes and the ability to layer programs was around long before the pipes idea was formally developed and implemented, although the actual implementation was a revelation in itself.
For several years Kernighan continued his work in developing Unix programs, mainly working with Al Aho and Peter Weinberger. Together, the three experimented a great deal with awk and its various implementations. Kernighan found the atmosphere at the Labs to be ideal for the development of Unix; in general, there were no restrictions on creativity. He compared it to Xerox PARC; nobody was assigned a specific task, but the atmosphere was such that one would quickly find a project to work on. Management did an excellent job of staying out of the way; there were no demands for immediate results, although once a year workers were called upon to justify their work and explain its significance or long-term benefits. Programmers were rewarded if their project could be seen to somehow have an impact on the company, on the community, or simply on the body of knowledge in the field. It was the hands-off approach of management, as well as the fact that everything the programmers designed was for their own use, that led the team at Bell Labs to be so successful. Kernighan believed a programmer could not successfully write a program unless the programmer himself had a use for it.
Kernighan has been called the "group's scribe" because of the amount of time he spent writing for and about Unix. His first significant writings were tutorials for various Unix programs, starting with a simple set of instructions for Sandy Fraser's secretary on using qed; eventually, he wrote a complete tutorial on the B language. His ability to write about programming led him to examine just how programmers were writing programs; he found that most programmers had terrible techniques due to a lack of proper training. He and Bill Plauger set out to write The Elements of Programming Style, which did for programmers what Strunk & White's book did for essay writers. Like the famous grammar text, Programming Style explained how to program correctly by using examples of bad programming, largely drawn from contemporary textbooks.
Through his work with Unix and in writing Programming Style, Kernighan developed a method and philosophy of programming that grew in importance as Unix itself grew. He developed the idea of "little languages," which essentially was a manifestation of the software tools notion. Given a specific task, Kernighan could write something similar to a language compiler designed to handle one specific problem. The idea was appealing because it was exactly analogous to compiling in a complete language, but done on a small enough scale that one person could complete the task, and allows the programmer freedom to make his own rules. Again, although he was clearly instrumental in developing little languages, Kernighan claims he did not realize the full impact of little languages until much later, and is reluctant to take full credit for the idea.
In his work Kernighan also experimented with writing
structured and unstructured programs. He found writing
structured programs (programs that did not use goto's)
difficult at first, but now he cannot imagine writing programs in
any other manner. The idea of recursion in programs also
seemed to develop slowly; the advantage to the programmer was
clear, but recursion statements were generally perceived as
expensive, and thus were discouraged. Kernighan found that
hardware manufacturers, especially DEC, eventually made recursion
a more feasible option. In Kernighan's view, however, Unix
made the hardware largely irrelevant; the ease of portability
meant that virtually any machine was capable of running
Unix. Once again, flexibility proved to be the most
significant aspect of Unix; it was this flexibility that was
paralleled in all of Brian Kernighan's work.