27 Sep 2018
What makes a good program?
Let’s ask a different question: What makes a good scientific theory or a good mathematical proof? Being correct helps, obviously – that is, a true scientific theory is better than an untrue one. Thus, a program that works and is correct is better than one that fails, errors, and is incorrect. But scientific theories have a habit of turning out to be false, as is expected: science advances and explains more, and in doing so overturns old theories. Mathematics may be more apt here. Logical necessities do not get overturned, afterall.
But in either case, there is a commonality between good scientific theories and rigorous mathematical proofs: they both can be said to be elegant and beautiful. And not only is the end result a beautiful proof, the process itself is motivated by beauty. The physicist Dirac, writing in 1981, noted that much of his work has simply been “a search for pretty mathematics.” Roger Penrose, more recently, has written of the importance of aesthetic judgement in his mathematical and scientific work; and Hadamard upon reviewing innovation in mathematics remarked that innovative ideas are “imperatively goverend by the sense of scientic beauty.” Penrose, in fact, even went on to say that “rigorous argument is usually the last step! Before that… aesthetic convictions are enormously important.”
This is a sentiment that I also have gathered from my time studying the history of science, and my own study of linguistics. Beauty and elegance are vitally important criteria in terms of whether some theory is good or not. The reason beauty is imporant for theory construction, I do not know. Though we may take a guess from Penrose, “a beautiful idea has a much greater chance of being a correct idea than an ugly one.”
Nonetheless, returning to what makes a good program, we must not forget the aesthetic. Programs may appear to work, may appear to be correct, but an ugly program is not a good one. And as such, the good programmer is like the good scientist: not just knowledgeable about the domain specifics (algorithms, data structures, and so on), but one who also has formed an aesthetic judgement for what makes a good program – such a person evaluates the beauty of a program, discarding the ugly in favour of the elegant.
- Dirac, P. A. M., 1981, ‘Pretty Mathematics’ In International Journal of Theoretical Physics, Vol. 21. 1982.
- Hadamard, cited in Penrose (below).
- Penrose, R., 1989, The Emperor’s New Mind. Oxford Landmark Science