Kernighan's lever

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it? — The Elements of Programming Style, 2nd edition, chapter 2

It is tempting to interpret Kernighan’s aphorism as a warning: Stay away from clever techniques, it seems to say, because if you write clever code, you will never be able to get it to work. But this interpretation is unfortunate, and rests on the false assumption that cleverness is static. … You effortlessly wield clever programming techniques today that would’ve baffled your younger self. (If not, then I’m afraid you stopped evolving as a programmer long ago.) But this improvement is the result of practice, and something must have motivated you to put in all those hours of work. Kernighan’s witty remarks provide a clue: In programming, as soon as you work at your current level, you will automatically end up in a situation where you have to work beyond your current level. By means of this very fortunate mechanism, you will leverage several basic human drives (honour, pride, stubbornness, curiosity) into providing the motivation necessary for improvement. - I call this mechanism Kernighan’s lever

Written on May 6, 2019, Last update on September 15, 2021
software debug quote