图灵访谈之二十二：专访Brian W. Kernighan
K&R C和AWK中的K都代表“Kernighan”。他和Dennis Ritchie合著了C Programming Language，他发明了AWK和AMPL编程语言。C Programming Language是世界上第一本被广泛认可的C语言教程，平实、优雅、简洁，已成为编程语言教程中的绝佳典范。作为贝尔实验室的计算机科学家，Kernighan曾与Unix系统的创造者Ken Thompson和Dennis Ritchie一起工作，在这个影响深远的系统中留下自己的印记。
在贝尔实验室工作30多年后，Kernighan开始在普林斯顿大学教学，他的新书D is for Digital 解释了计算和通信领域的运作方式，并讨论了新技术带来的社会、政治和法律问题。他认为，今天每个人都应该知道这些。这本书简洁不简单，即使阅读的人没什么技术背景，也不妨碍他们理解书中的世界。
图灵社区有幸邀得Brian W. Kernighan接受访谈，畅谈他与CS的半个世纪。访谈中，除了意料之中的睿智外，更令我们感动的是大师对CS的那种50年不变的执着与活力。
iTuring: Many thanks for granting us the translation rights of D is for Digital and doing an interview with us.
You once mentioned, you entered the computer world entirely by accident in 1960s and took then budding Computer Science as your major in Princeton University. Now that almost 50 years have passed, and you are a professor of Computer Department there. How do CS students nowadays differ from the old generations? And has your viewpoint toward the industry changed?
Brian W. Kernighan: When I entered graduate school at Princeton in 1964, there wasn't a separate computer science department, just a small number of professors in the electrical engineering department who were interested in computers. So computing was a totally new field, and many people, even the faculty, had very little experience. This made it a lot of fun, since everything was new and everything was potentially something where a contribution could be made. Today, nearly 50 years later, computer science is still a young field by comparison with say physics or mechanical engineering, but it's definitely much closer to being “mature”. That means it's harder to make fundamental discoveries, and that there is much more specialized material to learn before one is well educated in the field. When I was a graduate student, students came with all kinds of backgrounds, like physics or mathematics or electrical engineering; today, essentially all grad students in CS have an undergrad degree in CS. And at the undergrad level, a fair number of entering students have done a significant amount of computing in high school or even earlier, though not everyone has. Experience and specialization come earlier and earlier.
Of course the computing industry has changed too, enormously. When I graduated, the field was most influenced, even dominated, by large companies like IBM and AT&T, where I worked. (Bell Labs was part of AT&T.) Those companies mostly built hardware, and any software aspect of what they did was almost incidental, a way to sell hardware. Today, although there are similarly influential companies like Microsoft and Google and Apple, they don't span the great range of activities that the earlier hardware companies did, and they aren't nearly as large. AT&T had well over a million employees in 1970; Microsoft is less than a tenth of that today. But the steadily decreasing cost of hardware and the growth of the Internet have made it possible for anyone with a good idea to start a company with nothing else, and (with luck) grow with amazing rapidity. Google is only 15 years old; Facebook is only 8 years old; Instagram, which was just bought by Facebook for a billion dollars, is a year and a half old. It's clearly a great time to be an entrepreneur in computing, and one big change that I see in students is that many of them are strongly interested in starting their own companies. 50 years ago that would have been pretty difficult; now it's easy. Of course it's probably just as hard to be a great success, but the barriers to entry are low, so many more people are able to try.
iTuring: Looking back on your nearly 50 years' professional career, what valuable experiences or even failures would you like to share with Chinese readers? Here we have millions of students and professionals studying and working in computer field.
Brian W. Kernighan: My students often ask me for career advice, and my answers are based on what has worked or hasn't worked for me. I don't think that I have any special insight, but it has always seemed to me best to do something that you really enjoy doing. If you have a job that is fun, where you are eager to start in the morning and hate to quit in the evening, that's what you want. Learn as many different areas as you can, since often the most interesting computing arises when computers are applied where they haven't been previously. Louis Pasteur once said that “chance [that is, good luck] favors the prepared mind.” So the more things you know about and have thought about, the more likely you are to recognize an opportunity when it arises. Learn to speak and write well, especially to people who are not experts in your fields, since those are skills that will serve you well no matter where your specific technical activities take you. Work with the best people you can find, and learn from them.
iTuring: You must have taught many Chinese students and worked with some Chinese IT professionals. So what do you think are the common features of Chinese students who have no American education background or working experiences before? What do they need to improve?
Brian W. Kernighan: I've had some absolutely wonderful Chinese friends and colleagues, going back to graduate school days if not before, and right up to today, where I have Chinese graduate students among the teaching assistants in my courses. What a great bunch of people! I think the main concern for many Chinese students who come to the USA is coping with rapid colloquial English. It takes a lot of time and practice to become fluent in another language, and of course it's a lot easier if one starts very early. It's important to consciously work on language skills, and to place yourself in situations where you really do have to cope, for example gatherings where everyone else doesn't speak your language.
iTuring: As we all know, you have authored or co-authored several classic books on computer science. These books are quite popular among Chinese readers. Some curious people just wonder whether you have ever received some special training at technical writing. Would you please describe your typical writing process?
Brian W. Kernighan: Some authors claim to write things once and never revise them, but that's not the way I work. I think for a long time about what I want to say, and I take a lot of time on the organization and basic content of a big project like a book, but once the basic idea seems right, I just start to write. I try to get the words down as quickly as I can so I have a decent first draft. Then I spend a lot of time revising; that first draft will go through many revisions as I try to get the sequence of material right and the detailed sentences and individual words to sound right. Of course, this eventually reaches the point of diminishing returns, or I run out of time, and then it’s done. But the basic approach is to do a very large number of revisions.
iTuring: Lots of Chinese have read your K&R C book. Many people even guess you are a developer of C language. What do you think are the factors that make C language remain popular through over 40 years?
Brian W. Kernighan: I think that C still has the best balance between efficiency, expressiveness, and size of any programming language. No other language produces code that runs as fast, and no other language yields such compact programs over the whole range of programming. C is also very good for getting close to the real hardware without descending to assembly language. So C is likely to remain a good choice when efficiency matters a lot, and when code size matters. If I were going to write a program to manipulate a lot of textual material, I probably would use a language like Python, but if I were going to write an operating system or a device driver or a similar system where efficiency mattered and where it was necessary to be in complete control of the hardware, I would use C.
iTuring: When Dennis Ritchie passed away last year, quite a few posts were written or translated in our website as a memento to him. As a co-writer and good friend of him, would you mind recalling some most impressive things about him?
Brian W. Kernighan: Of course Dennis was an extremely smart person, and a great programmer, but the things that I treasured most about him were his kindness and generosity, and his wonderful sense of humor. As an example of his generosity, when Bill Plauger and I were writing Software Tools, we thought it would be valuable to include a simple macro processor as an illustration. I tried to write one, but it was awful and it didn’t work. To help us, Dennis created a macro processor that he called m4, which was exactly what we needed. We used it in the book, and it's still used on Unix and Linux systems. Dennis never took any credit for this; it was just a way for him to help his colleagues. And of course the famous comment /* You are not expected to understand this. */ in the Unix 6th edition source code is a fine example of his dry wit.
iTuring: You always pay close attention to the development of programming languages. And some of your colleagues from Bell Lab were involved in the design of Go language. How do you see this "C+Python" language?
Brian W. Kernighan: I have only looked at Go casually, so I don't know it well enough to predict anything about how much it will affect the world. Realistically, it's very difficult to establish a new language, since there is so much inertia with existing languages. A new language has to be very much easier to write, or it has to work especially well in a new domain, before it's worth the effort to use it. I have great respect for Ken Thompson and Rob Pike, who created Go, and there are some very nice features in the language, but I think it will be hard work to establish it as a major language with the same success as Python has had.
iTuring: We notice that you worked with many people on books or software development, and you always come up with great works. You are really a wonderful team player. Do you mind sharing some teamwork techniques and talking about some co-workers who impressed you most?
Brian W. Kernighan: I've always been very lucky in having exceptional colleagues; Bell Labs was a great place to work because there were so many great people there, in an environment that encouraged cooperation. So working with other people was just the normal mode of operation. From a personal standpoint, I think it's better to work with people who are better than you are, since you learn more from them; of course, this was not hard at the Labs: since there were so many exceptional people, it was hard to avoid working with better ones. The other thing that I think is important is to not worry about who gets credit for the work. It's always better to just do something and not think about who did what part of it – cooperation instead of competition. And the result was always better by having the contributions of multiple people than it would have been with only one person. This is of course especially true of writing books, where having two or three authors is far better than having just one.
iTuring: D is for Digital is the latest book you wrote on your own. How did you conceive it? And how does writing alone differ from coauthoring? By the way, why do you give it this name? And it reminds me of the C book.
Brian W. Kernighan: I've been teaching a Princeton course about computers and communications for 12 or 13 years, to a very non-technical audience. The students in the class are very smart, but their interests are in other areas than computing. So it's been a fun challenge to try to present technical material in a way that they will appreciate. I never found a good textbook, so I decided to write my own, based directly on the material that is covered in class. This is the first book that I've written without a coauthor, and I quickly came to realize how much I had depended on really talented people like Dennis Ritchie and Rob Pike; it's much harder to write alone, and there's no sanity check, someone making sure that the material makes sense and is accurate. Fortunately a bunch of friends read drafts very carefully; that was an enormous help. The title itself came from a talk that I gave at Princeton back in 2003; it just seemed better than any of the alternatives, and of course the parallelism with The C Programming Language was a happy coincidence.
iTuring: One thing that makes D is for Digital different from your previous works is that it is written for non-technical students. In your opinion, what role should computer play in the life and work of non-technical people? How should they get to learn computer science?
Brian W. Kernighan: I don't think that non-technical people need to learn computer science, but it's important that any educated and well-informed person understands some of the basics of a technology that is so central to life today. Computers are a pervasive part of our world, and it's necessary to have some grasp of what they do, how they do it, and how they affect our lives; otherwise, there's no chance that we will control how computers are used. If you have some idea of how the Internet works, for example, you're more likely to be able to defend yourself from scams and fraud and perhaps protect your privacy. If you understand how your cellphone works, you're probably better able to understand its limitations and some of the perils of downloading random apps.
iTuring: During our communication about D is for Digital, you mentioned that your big concern was the quality of the Chinese version. Did you have any bad memory about poor translation of your books?
Brian W. Kernighan: Well, I certainly don't have any concerns about the quality of the Chinese translation! In the distant past there were a couple of poor translations in European languages, apparently because the translators didn't understand the technical material well enough, and thus used terminology that wasn't right in the particular language, or got some of the technical facts wrong. Again, I've been fortunate in having friends and colleagues who are fluent in various languages, and they are able to give me an accurate assessment of how well a translation is done.
iTuring: Apart from teaching and writing, are you engaged in any other computer-related work? Are there any new or interesting ideas you'd like to share with Chinese readers?
Brian W. Kernighan: Teaching occupies me pretty much full time during the school year. During the summer, I often work at Google in New York, which is a great experience, often on things related to Google Docs. I've been interested in document preparation software for a long time, so it's a good match. And during the school year, I try to experiment with a variety of languages and tools so I can teach better. But computing is such a rapidly changing and expanding field that it's difficult to keep up; I'm sure that your readers experience this too!
iTuring: Thanks a lot for your time.