Skip to content
CONTACT

Law of the lying comment

PROGRAMMING AND BUGS

When the comment and the code disagree, both are probably wrong.

— Anonymous, computing folklore
VIDEO.EXE16:9

Comments are the sentences programmers leave in the code to explain what it does. In theory they are an act of kindness towards whoever comes next. In practice they are like road signs for a road that has since been moved.

The code gets changed, the comment stays. So you find 'calculates the ten per cent discount' above a function that sends an email to the managing director. Who's right? Nobody. The comment tells of an ancient intention, the code of a modern accident.

There is also the opposite school of thought, the proud programmers who never comment: if it was hard to write, it should be hard to understand. I'm somewhere in the middle. I always comment, but with phrases like 'do not touch'. It explains nothing, but it saves a lot of lives.