Leading Programmers Remember the Impact of The C Programming Language
More than thirty years ago, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language, a concise yet definitive reference guide to the C language, initially developed by Ritchie at AT&T Bell Labs in the early '70s. At the time, K&R, as it came to be called, was the very first guide to programming in Cand since then has become a world-wide bestseller, translated into more than thirty languages.
The C Programming Language is available in digital formats (MOBI, EPUB, PDF, and in Safari Books Online) for the first time and includes a new preface from Brian Kernighan. Also be sure to read our recent interview with Brian Kernighan.
To celebrate this milestone guide, we asked the leaders in computer science to share their thoughts about The C Programming Language. Read on to discover what Bjarne Stroustrup, David Patterson, Andy Tanenbaum, and many others have to say.
Publication of the ``K&R C book'' was a landmark in Computer Science. I visited Bell Labs shortly after the book came out, and was talking with Brian about programming. He handed me one of his personal copies, and the book completely changed the way I viewed systems programming. Before C, programmers had been taught that high-level languages were only appropriate for applications and that the efficiency required for systems programming could only be achieved with tedious and error-prone assembly language. Suddenly, C made it possible to write systems in a high-level language that compiled to efficient code. Like many great discoveries, it seems obvious in retrospect, but was revolutionary at the time.
Soon after Brian gave me the C book, I began working on the Xinu operating system. The book was invaluable. With terse prose and excellent examples, the book explained everything needed. Except for a few lines of assembly language in the context switch and interrupt dispatcher, it was possible to write everything, including device drivers in C. Even interrupt disable/restore functions were handled by a C macro that invoked the asm construct.
C was especially meaningful to me because I was using VAX and PDP-11 computers from Digital Equipment Corporation. The Digital computers made it easy to understand C because many of the language facilities are abstractions of features from the Digital instruction set, memory architecture, and addressing modes. For example, pre- and post- autoincrement, which can seem puzzling to programmers, were derived from the Digital hardware. To a system designer, the correspondence between C and the underlying hardware makes it easy to envision how C could be used to achieve the desired sequence of operations.
The future is easy to predict: C will be around a long time.
Ironically, the major complaint raised about C is that it is "old." Perhaps younger programmers have fallen into the trap of applying the ubiquitous marketing statement "newer is better'' to programming languages. Ten years ago, for example, a young faculty member lamented that new languages were being ignored in favor of C. To me, his reasoning seemed backward. I asserted that as soon as someone invented a better language, it would be adopted. But until then, I suggest, we should stop viewing C's age as a negative and admit to ourselves that its longevity is a measure of its importance and usefulness.
My first encounter with K&R was in the early '80s, when I was a Pascal-trained math/physics-major undergraduate.
I dodged the mandatory "students must learn Fortran and card-sorting" bullet by about a year, by avoiding engineering courses in favor of math and science. I worked part-time as a computer lab assistant and sysadmin for a couple of DEC machines, the big one a DECSystem 2060 (36-bit processor).
A friend from high school introduced me to a prodigy who had dropped out of MIT to work as a consultant in very early '80s (last days of Disco) Silicon Valley, who was building his own wire-wrap Motorola 68000 system and bringing up Unix on it. Of course this meant C, and from that friend of a friend I first was exposed to K&R.
Something was indescribably beautiful to young-nerd-me about K&R. The font (Courier, I think). The 5-space-equivalent tabstops used to indent the code. The prose style, plain and pithy. The clear explanation of pointers, including declarator modes (which read inside out). The examples, e.g. binary search with chosen boundary conditions that I could verify based on induction from C's 0-based indexing, avoiding fencepost bugs. I was in love.
My ardor was not dimmed by the challenge of loading a Portable C Compiler 'port from the University of Utah on that funky old 36-bit DEC system. By then, I knew enough to be dangerous: int must be pointer-sized, char was possibly smaller than int -- but not necessarily, and in this case it was a full 36 bits (no SIXBIT hacks, we needed true ASCII).
Inspired by yacc but put off by its ugly output format, I wrote my own LALR(1) parser generator. I could not have done any of this without K&R, which I read and re-read and imitated endlessly.
"Here is a language [Algol 60] so far ahead of its time, that it was not only an improvement on its predecessors, but also on nearly all its successors." C. A. R. Hoare, Hints on Programming Language Design, December 1973
Tony Hoare's description fits K&R, too. It's (a) correct, (b) beautifully written, (c) well-edited, and (d) still the best textbook on the most important programming language. I believe it to be a near-perfect piece of technical writing.
A few years back, I went into a bookstore (remember bookstores?) looking for a new copy of K&R. I asked the clerk, who smiled and said, "We're out of that book, but we have a lot of other good books on the subject," and pointed to a wall of books on C and C++.
"No thanks," I said, "I'm just looking for K&R."
He said, "That's what everybody says."
I grinned and said, "What's that tell you about what you should you should be stocking?" He nodded.
I'm enormously happy to hear I'll be able to get K&R as an ePub book. If you brought it out in hardback, I'd buy that, too.
Kernighan's other great book is Elements of Programming Style. You could look at the book and say, "It uses examples in languages that no one uses any more," but that was even true when it was written; the authors (Brian and P. J. Plauger) admit it up front. The book is about programming, not particular programming languages. Here, too, I wish I had a pristine copy to replace my dog-eared one, but it's out of print. Perhaps someday it will ride over the electrons to my Kindle.
One summer during college, I had a really terrible job: I worked the late shift at the USAir Frequent Traveler Program call center. My phone would ring and someone would yell at me for a few minutes, I would apologize and they would yell at me some more. After they were exhausted from yelling, they would hang up, and my phone would ring again. This soul-deadening exercise went on until midnight.
Before returning to college, I located the coolest job in my neighborhood: being a researcher in speech recognition for the military. I asked the manager of the lab what they needed next summer. He said, "I need someone who can write C code for a UNIX machine." I swore to him that in the spring I would a great C coder.
It was 1987. I had done some Pascal programming, but knew nothing about C. I went to the bookstore, and there was a tiny white and blue book. I spent several weeks studying it. Each sentence was simple, clear, and information-packed. I don't think I have ever read a book so slowly.
My college had a few UNIX machines, but they were only available to graduate students in the engineering department. I was an undergraduate in the music department. I went to see the dean of electrical engineering and threw a temper tantrum in his office. Oddly, this worked.
I still remember being led to the Sun 3 hidden in a small windowless room. I figured out how to use the terminal and the editor, and typed in the first exercise: printf("hello, world\n");
I got the job at the speech recognition lab, and my life changed course. It has been 25 years, and every day I use the stuff I learned from K&R.
I first encountered K&R (in its 2nd, ANSI, edition) as a first-year graduate student. I had been programming a little before, but this was my first introduction to serious software development. For the next several years, K&R had a fixed place on my desk and remained an essential reference.
Today, K&R still stands out to me as an example of truly outstanding technical writing. In particular, I continue to admire the structure, which develops the content in an apparently natural flow, with rarely the need for a forward referenceand of course the concise and economic prose. Stone tablets, brought down from Murray Hill.
In fact, the style was so compelling that it never occurred to me to question any of the content. C is as concise and austere as K&R itself, and for many years I never doubted that this was the way programming had to be: without support for garbage collection, exception handling, regular expressions, hashmaps, or even proper strings. I believed real programming was supposed to be hard, and it took me a long time before I got over that idea.
I have not actually opened my dog-eared copy of K&R in several years, but I always keep it close at hand. I feel safer knowing it's theretogether with the three volumes of the Feynman Lectures and a copy of Abramowitz & Stegun.
It is hard for me to describe just how profoundly that book affected my career. I remember reading it by a campfire in my back yardmy original still smells of smokepuzzling over the code, and standing to cheer for the concepts. The simple elegance of the writing; the pragmatic outlook of the authors; the sheer beauty of the language thrilled me as no language had beforeor has since.
I used the K & R C book for my classes in C programming and data structures for years. The students had trouble with it at first, but by the end of the class they realized the book had required them to build tools they would re-use forever.
The C Programming Language is one of my favorite technical books of all time; I will keep it in my library forever. The thing I find most memorable about the book is how its technical descriptions are at the same time compact in word count, simple and easy to understand, and yet totally comprehensive in terms of covering every significant detail. I have seen books with five times as many pages that cover less material and are harder to understand.
C is the machete of programming languages. It's great for clearing a quick path through the jungle of programming problems, but be alert as there are no safety mechanisms to protect the wielder of this wonderful weapon.
Well, those people are wrong.
For various reasons too complicated to go into here, I believe that you have to start programming at a level that is as close to the machine as reasonable. I think that this book, universally known as K&R, is THE book anyone who wants to be a programmer must learn first. Pick it up and work through it in detail. If you love every minute of it, you can be a programmer. If you find this old-school text programming stuff boring, or the pointer stuff drives you crazy, trust me, you're not going to like programming very much. If you need to be seduced into programming or if you don't have the patience to figure out what all those crazy asterisks mean, you're going to be happier doing something else. Really. But if you can make it through this book by yourself, you've got what it takes to be a top gun programmer, and you've got a terrific foundation for everything else you're going to learn.
K&R is one of my favorite books. The style of the tutorial chapters is so deceptively light and simple and the manual so crisp. Much of C's reputation of simplicity comes from the clarity and great little examples from this book. My 1978 copy has lost its cover and my K&R2 is somewhat dog eared. Above all, K&R is a useful book.
This is certainly one of the most important books ever published in computer science. For decades, C and C++ have been the languages of choice for writing system code. This book has often been imitated, but it has never been equaled. It is a huge pity that Dennis is no longer around to be part of this event, but we will never forget him. He was a great scientist and wonderful person.