Cargo Cult Programming

Cargo cult programming is the practice of including code, configuration, or procedure in a project by imitation, because it appeared in a working example or “is just how it’s done,” without understanding what it actually does or whether it is needed. The result is code padded with superstitious incantations: redundant casts, defensive try/catch blocks that catch nothing meaningful, magic flags copied from a forum answer, all carried along because removing them feels risky and nobody knows why they are there.

The term borrows from Richard Feynman’s 1974 Caltech commencement address, later published as “Cargo Cult Science.” Feynman describes South Sea islanders who, after wartime cargo planes stopped coming, built mock runways, lit fires along the sides, and put a man in a wooden hut “with two wooden pieces on his head like headphones” to act as the controller. They reproduced every visible detail of the airfields they had seen, and waited for the planes to land. The planes never came, because the form was right but the essential thing that made the planes arrive was missing. Feynman’s point was about science that follows all the outward rituals while lacking the underlying integrity, and the analogy transferred cleanly to programming.

In code, the cargo is a program that works, and the cult is the developer who copies its surface forms hoping the same result will follow. A classic example is the novice who, seeing a sample that wraps everything in a particular boilerplate, faithfully reproduces the boilerplate in a context where it does nothing, or worse, where it silently breaks things. The copied ritual is preserved long after its original justification is gone, becoming a small piece of technical debt that resists cleanup because its purpose is unknown.

The pattern is not always a personal failing; it is built into how programming is learned and how large systems accrete. Stack Overflow answers, framework starter templates, and inherited legacy code all invite copy-and-adapt, and under deadline pressure, copying a known-working block is faster than fully understanding it. The danger is that imitation without comprehension produces code no one can confidently change, since any modification might disturb a load-bearing incantation that only looks decorative.

The remedy is the same one Feynman urged for science: the discipline to understand why something works before relying on it, and the honesty to admit when you do not. In practice that means reading the documentation behind a copied snippet, deleting code you cannot explain and seeing what actually breaks, and using code review and clear comments to surface assumptions. Cargo cult programming is, at bottom, a failure of understanding wearing the costume of competence.

Sources

Last verified June 8, 2026