With book on new computer language, Kernighan guides students at Princeton and beyond
As an undergraduate, Rob Pike first read Brian Kernighan's book on the C programming language while home sick from classes at the University of Toronto.
"I lay in bed and I read it cover to cover," said Pike, now a top software engineer at Google. "It was quite a small book but it contained at the time the most complete, precise definition of the language."
Thirty years later, Pike and colleagues at Google have written a new computer language called Go; and Kernighan, now a professor of computer science at Princeton, has co-written the book on it — "The Go Programming Language."
"In the summer of 2014, I tried to convince Brian to write an introductory book on Go," said Alan Donovan, a member of the Go design team and Kernighan's co-author. Donovan said he was hoping for a reprise of the C book, which he called the most influential book in the history of computers. "In response, he made me an offer I couldn't refuse — to write one together — and thus began an intense but tremendously rewarding 14-month collaboration."
Pike said the true value of both books was concision without the loss of comprehension.
"What Brian brings to it is a very gentle manner of talking about very technical stuff so you understand it without being buried in the details," said Pike, who is an author of four languages including Go. "He is very good at boiling things down."
Kernighan's particular ability to distill complex subjects for computer professionals and for students has been a hallmark of his career. Whether teaching an advanced programming class, overseeing an independent study project or writing a column for The Daily Princetonian student newspaper, Kernighan makes complicated subjects short, precise and clear. He has used the same approach in mentoring students.
"He has the perfect balance between being hands-on and allowing you to work independently," said Hannah Swenson, who worked with Kernighan on her junior-year independent research project developing an online clothing exchange. "He is a great resource and is able to answer any questions you have, but he never pushes any given idea."
Kernighan, who earned his Ph.D. in electrical engineering at Princeton in 1969, began working with computer languages as a graduate student. Before returning to the University as a professor in 2000, Kernighan spent 30 years at Bell Labs, where he headed the Computing Structures Research Department. He worked in the same group as the team that developed the Unix operating system, which still powers many computers worldwide.
In the Unix group, Kernighan worked alongside Dennis Ritchie, who created the C programming language, which is one of the most commonly used computer languages. Kernighan teamed up with Ritchie to write a book about C, which quickly became the standard guide for the language. Known among programmers simply as "K&R C," it inspired generations of programmers, including Pike. Among other things, the book is noted for popularizing the use of a simple program instructing the computer to print "Hello World" as a test or introductory example.
The book helped introduce a generation of students to programming. Kernighan himself did similar work in the classroom. Over the years teaching at Princeton, he inspired and informed a wide network of students and colleagues.
"The first week I arrived at Princeton, Brian was a visitor from Bell Labs and gave a seminar on computer science that I attended as a freshman," said Eric Schmidt, a 1976 alumnus and the executive chairman of Alphabet, the parent company of Google. "I was a self-taught programmer in high school and I did not know anything about computer science at all. Based on this talk, I decided I should become a proper computer scientist."
For students like Swenson, a senior concentrating in computer science, Kernighan's knowledge of the world outside Princeton can be as helpful as his computer science skills.
"He has kept up with a lot of people and knows who is enjoying their jobs and who isn't," said Swenson, who will be working as a programmer for Goldman Sachs after graduation. "His main advice is that everyone has different ideas and everyone has navigated the working world in different ways — so try what you like and you can always switch to something else."
Swenson said that Kernighan agreed to act as a second reader for her senior thesis, even though Kernighan is on academic leave this year.
"He is on sabbatical," she said. "He is not even technically a teacher this year. But he has come up with great ideas and has been really helpful."
Kernighan worked at Google's New York office in the summer of 2014, and began collaborating on the book with Donovan, his Google mentor. They worked on it over the next year and finished it over the summer and fall of 2015.
"When we were choosing among typesetting systems, Brian never let on that he was one of the original authors of Troff, the system we ultimately went with," Donovan said. "I realized this only after researching many early papers on digital typesetting; Brian co-wrote all of them."
Like Donovan and Kernighan's book, the Go language itself began as a side project. Under Google's "20 percent" program, which allows employees time to spend up to a fifth of their time working on side projects, Pike and colleagues Robert Griesemer and Ken Thompson began working on Go as an alternative to the C++ programming language, the current standard language for many uses. They wanted a new language that was less complex and more efficient at handling certain tasks.
"Some people say Go is C for the 21st century," Kernighan said. "As a language, it is very lean and efficient."
Go is an open-source program, meaning that all of the code that makes it work is available for anyone to see and tinker with. It is designed to address the demands of concurrent processing — the modern technique of making computers faster by dividing their work among multiple processors working at the same time. Clarence Rowley, a professor of mechanical and aerospace engineering at Princeton, said the technique has become critical in many areas of science and engineering where it's no longer feasible to force more speed from a single chip.
"You have to think in parallel," he said. "The question is how can I spread my work over dozens, if not hundreds or thousands, of processors?"
Nick Feamster, a professor of computer science and the acting director of Princeton's Center for Information Technology Policy, is using Go in some of his networking projects, which involve concurrent computing.
"They thought about concurrency at the design stage," Feamster said. "There are ways that the language provides for shared memory and multiprocessing."
Feamster, who read the Go book in a draft form, said Kernighan's books are known for accessibility without loss of depth.
"It introduces the language at just the right level," he said. "The C book, of course, is famous in that regard."
Kernighan says he was not attempting to replicate his earlier works with his most recent project. The goal, he said, was to produce something that introduces the language and helps programmers take advantage of its strengths.
"Programming can be hard, especially for big programs, but there's a great feeling of satisfaction when a program works," he said. "I've always tried to help ordinary programmers to write better code and have fun while they're doing so."