cargo cult programming
loreprogrammingops culture
Copying code or rituals that seem to work without understanding why, in the hope the result follows.
The phrase adapts Richard Feynman's "cargo cult science": going through the motions and expecting the outcome to appear. In code it looks like pasting a config, an incantation, or a boilerplate class because it worked somewhere else, without grasping what it does. The cure is understanding, not more copying.
Cargo cult programming is copying the form of something that worked without understanding why it worked. The configuration block gets pasted in because a search result had it, the flag is set because a colleague sets it, and the code is correct in appearance and hollow in mechanism.
The name comes by way of Feynman's 1974 Caltech address, where he described cargo cult science as work with all the outward apparatus of rigour and none of the substance. The metaphor is drawn from post-war Pacific islands and is worth handling carefully, since it patronises the people it describes; the software usage has drifted far from the anthropology and mostly names a failure of curiosity rather than a failure of intelligence.
What makes it worth naming is that it is invisible from the outside. Working code and cargo cult code look identical until conditions change, and then the copied thing fails in a way nobody can diagnose because nobody ever knew what it did. The test is simple and uncomfortable: can you explain what this line does and what breaks without it. If not, you have not written it, you have transcribed it.
Also known as: cargo cult, cargo-cult
Sources
- after Feynman's "cargo cult science", 1974