More than 230 C programming language enthusiasts and others gave Brian Kernighan — who cowrote the seminal book on C with the late Dennis Ritchie — the star treatment at the May 29, 2013, Princeton Tech Meetup.
The Princeton Tech Meetup is one of the larger meetups in the state with more than 1500 members. Organized by Venu Moola and Chris Boraski, it meets monthly, usually at the Princeton Public Library.
The modest Kernighan was, as always, quick to point out that he didn’t write the language itself, only the book, but for most in the standing room-only audience, that was enough.
Kernighan is the author of several smaller, more specialized languages that many in the audience knew. Still in the computer science field, he teaches in the department of computer science at Princeton.
In a presentation entitled “How to Succeed in Language Design Without Really Trying,” Kernighan spoke about the proliferation of computer languages, noting that even 52 years ago people were complaining that there were too many programming languages.
“I’ve spent a fair amount of time over my career designing and implementing about a dozen languages, most of them pretty small. Some of them are in use today, oddly enough,” he told the group.
What makes a language likely or not so likely to succeed? Kernighan asked the group, then tried to answer that question in his presentation.
Making the case for “small” specialized, application-specific languages, Kernighan provided a few examples such as AWK, AMPL and EQN. He was once quoted as saying that if he were marooned on a desert island with only one programming language, he would choose C (a general purpose language), he said.
But sometimes you need a more robust language that can be invulnerable against attack. It’s fitting to have a notation that is appropriate to the task you want to solve, he said.
You also have to take into consideration development time, said Kernighan. A particular task might take a programmer using a general-purpose language 20 minutes to program, while the same task could take just a few seconds to accomplish using a specialized language like AWK. Development time equals cost, he pointed out, if you have to pay programmers to write code. For many tasks efficiency doesn’t matter, but there are numerous applications that require coding efficiency. Also, languages that allow you to make effective use of time and space are going to be more successful, he said.
Small languages, said Kernighan, are focused on one particular topic area, one domain. Because of that focus they can be a lot smaller than a mainstream general-purpose programming language like C++. Small languages narrow the gap between what programmers would like to say and what they need to say to get the machine to do their bidding. Notation helps programmers focus on that, he added.
Speaking further about AWK, a language he invented with Alfred Aho and Peter Weinberger at Bell Labs in the 1970s, Kernighan said the design principle behind it was “what could we do to make useful computations in only one or two lines of code? One of the things we did to make it easier to use was get rid of much of the baggage that bogs down other languages, he said. AWK does a lot of things automatically, he added, to make it small and elegant.
“We learned a lot of lessons with AWK. One … is that it is hard to get things right the first time, as everyone knows,” Kernighan said. He presented a list of failures attributed to AWK but he called the language a fundamental success because people used it and discovered all its problems.
For example, “We never thought about internationalization because when we were doing this, we were in the United States, and who else in the world would ever use it?” Also, when you build a language for a particular task, something the designer thinks users will want, “people start to do all sorts of other screwball things with it,” Kernighan pointed out, noting, “I think that’s a measure of success.”
Another language Kernighan was involved in developing is AMPL, which is used to describe optimization problems, such as linear programming. AMPL deals with a collection of variables whose function you want to optimize, he explained.
Using the example of having to feed a bunch of people without serving alcohol, too much sugar, too much fat and so on, Kernighan said this problem can be mathematically described. AMPL is not just a language to specify a model for solving this kind of problem — it is one that expresses the data used in solving the problem, he said. It is widely used in corporations; airlines use it for crew scheduling, for example, and in finance. The language grew, he said, as people added on to it and made it do things it wasn’t intended to do, and, he lamented, it became uglier in its syntax. However, it was successful.
EQN is another small language Kernighan helped write that was an attempt to capture the language mathematicians use to talk to one another when reading equations aloud.
Said Kernighan, “The inspiration for this language may have come indirectly from something I did as a student… I read textbooks for the blind. Once a week I would go over and read texts and documents to be recorded. That gave me the idea that you could actually speak mathematics out loud in a form that you would have a chance that someone would understand.”
Successful small languages become widespread more easily when they use some aspects that people already know, Kernighan noted. For AWK, the group had picked a syntax that was already in C, which most people knew.
It’s also helpful that the language not be too big a leap for users to learn; people have to ease into a language, he indicated.
“I believe that AWK survives because there aren’t too many languages that tackle one-line programs well. It had weak competition,” said Kernighan. Also, he added, you can’t discount the role that good luck plays. A niche can disappear, or sometimes there are unfortunate engineering choices. A language can become bogged down and bloated.
In his conclusion, Kernighan was optimistic about there being room for even more small languages. He urged the Princeton Tech Meetup attendees to go home and invent “the next 200.” Of course, that remark received laughter and applause.