By Ian Cottam, IT Services Research Lead, The University of Manchester.
The next post in my series on heroes of software engineering focuses on Brian Kernighan. First of all an apology to my hero: I’ve been mispronouncing Dr Kernighan’s name for the last 35 years. In checking some facts for this blog piece I now realize the g is silent. Did you know that?
I suspect most readers will think my title refers to The C Programming Language by Kernighan and Ritchie: one of the world’s most popular books on programming and a programming language. Some people refer to this book as simply K&R, whilst others reserve that for the version of the C language that existed before ANSI standardised it. However, Kernighan’s only contribution to C, as a language and an implementation, is writing most of that book. (Ritchie wrote the chapter on system calls and the reference manual part.) The definition of C and the first C compiler were entirely Ritchie’s work.
Kernighan is one of software engineering’s greatest writers. To me, he is the living embodiment of what the formalist’s formalist (Dijkstra) said any programmer needs:
“Besides a mathematical inclination, an exceptionally good mastery of one’s native tongue is the most vital asset of a competent programmer.”
These days we tend to favour the “mathematical inclination” over the “mastery of one’s native tongue”, but Dijkstra knew they are equally important. However, I’m not including people in my blog series for the quality of their writing – that would tend to bias it towards academic computer scientists, who are paid to publish over anything else. I am interested in good design and implementation: the transformation of the abstract into the executable.
My K is the K in AWK – one of my all time favorite programming languages. (The A is for Aho and the W is for Weinberger, Kernighan’s co-designers.) Of course, the definitive book: The AWK Programming Language is just as well written as the more famous C one.
In my own programming, and where C is not needed, AWK tends to be my language of choice (for example, see condor_lint). It is a beautifully designed and sparse language for data manipulation. It shows great taste. Brian Kernighan first implemented it under UNIX version 7. I recall at the time version 7 UNIX became available many people said you should update for two simple reasons: the first was the famous Make utility and the second was AWK.
These days, I suspect more people write their data manipulation programs in Perl. One of the world’s ugliest languages, in my humble opinion. Why do they? I have never quite fathomed it, apart from the fact that AWK was rather tied to UNIX (and the UNIX shell) in its early days. At least Python seems to be stealing some of Perl’s thunder, but I would urge you to consider the original and still the best: AWK! Read the book and Aho, Weinberger and Kernighan’s fine rhetoric will convince you to try my hero’s finely engineered implementation (or even, and more likely these days, the GNU project’s excellent clone).