Brian Kernighan on Successful Language Design

The focus on 1-liners led Kernighan to devise specific features of the language, such as the absence of type declarations, automatic initialization, built-in variables, operators working on both strings and numbers, support for associative arrays and regular expressions, control flow statements, and built-in functions.

Also significant were the lessons that Awk made possible. First and foremost, that people use tools in unexpected ways, as well as that mistakes are inevitable and hard to change. In particular, it is fundamental for Kernighan to avoid adding new features to a language or even try to fix or improve specific things, since this will impair the language stability. Furthermore, new notation added as an afterthought generally brings a lack of consistency in the syntax.

The second example that Kernighan presents is AMPL, an algebraic modeling language for solving optimization problems based on a set of variables and constraints on their values. Kernighan was co-designer of the language as well as its initial implementor. AMPL provides a declarative syntax, which allows you to describe the problem’s variables and their constraints. AMPL also provides a data specification language for describing the data, and a command language to control what AMPL does.

According to Kernighan there were a few features of AMPL that made it moderately sucessful. In particular, due to its narrow focus on a specific kind of problems, universities taught it and it was quickly adopted in the industry. Its notation was initially purely declarative. Later more mechanisms were added, such as conditionals, loops, functions, i.e. what typically makes languages Turing-complete. This brought also some odd and irregular syntax. Another particular aspect of AMPL is its being closed-source, which surely contributed to its success, but, Kernighan says, it is one of those things that could be argued about.