Glossary termAnti-pattern

Cargo Cult Programming

Also known as: Cargo cult software engineering

Ritual use of code, tools or practices copied from elsewhere without understanding why they work or whether they serve any purpose.

Cargo cult programming is the habit of including code, configuration or procedures in a program because they appeared somewhere else, not because the programmer understands what they do. Examples include copying a block of code from an online answer along with lines irrelevant to the problem; keeping checks or settings that once seemed to fix an unrelated bug and are retained out of habit; and adopting a famous company's architecture or process wholesale in a context where its original reasons do not apply. The result often works by accident, if at all, and is hard to maintain.

The phrase borrows from the physicist Richard Feynman's 1974 Caltech commencement address on cargo cult science, which criticized research that imitates the outward forms of science without its substance. Feynman drew on accounts of movements in Melanesia, often called cargo cults, in which people were reported to build imitation airstrips in hopes of attracting the supply flights seen during the Second World War. Anthropologists have noted that such accounts often oversimplified complex religious and political movements, and some consider the term reductive; in programming it is used only as a metaphor for imitation without understanding.

The antidote is understanding: knowing why each line exists, reading documentation, testing assumptions and removing code whose purpose cannot be explained. Practices such as code review, in which reviewers ask what a change does and why, and refactoring to delete dead code help expose cargo cult patterns. The issue has drawn fresh attention as developers copy from forums such as Stack Overflow and accept output from AI coding assistants, including the style known as vibe coding, where code that runs may still be poorly understood. Unexplained code is a form of technical debt, since it is costly to change safely.

Key points

  • Cargo cult programming copies code or practices without understanding their purpose or relevance.
  • The term derives from Richard Feynman's 1974 critique of cargo cult science.
  • Code kept only out of habit or superstition is hard to maintain and may hide real bugs.
  • Code review, testing and refactoring help expose and remove unexplained code.

Related entries

Glossary term

Technical Debt

Programming

Metaphor for the future cost of rework created when software teams choose a quick or expedient solution instead of a cleaner, more durable one.

Glossary term

Code Review

Programming

Practice in which developers examine each other's source code changes to find defects, share knowledge and keep the codebase consistent.

Glossary term

Refactoring

Programming

Process of restructuring existing code to improve its design, readability or maintainability without changing its external behavior.

Technology

Stack Overflow

Programming

Question-and-answer website for programmers, founded in 2008, where users ask and answer technical questions and vote on the best answers.

Glossary term

Vibe Coding

AIProgramming

Style of programming in which a person describes what they want to an AI model and accepts the generated code largely without reading it closely.

Glossary term

Design Pattern

Programming

Reusable, named solution to a commonly recurring problem in software design, described as a template rather than as finished code.

Glossary term

Hacker Culture

Ideas and CultureCybersecurity

Subculture of people who enjoy exploring systems, solving technical problems creatively and sharing knowledge, rooted in early computing.