Cargo cult programming is a style of
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
characterized by the ritual inclusion of code or program structures that serve no real purpose. Cargo cult programming is symptomatic of a programmer not understanding either a bug they were attempting to solve or the apparent solution (compare
shotgun debugging,
deep magic
In the context of computer programming, magic is an informal term for abstraction; it is used to describe code that handles complex tasks while hiding that complexity to present a simple interface. The term is somewhat tongue-in-cheek, and of ...
). The term ''cargo cult programmer'' may apply when anyone inexperienced with the problem at hand
copies some program code from one place to another with little understanding of how it works or whether it is required.
Cargo cult programming can also refer to the practice of applying a
design pattern
A design pattern is the re-usable form of a solution to a design problem. The idea was introduced by the architect Christopher Alexander and has been adapted for various other disciplines, particularly software engineering. The " Gang of Four" b ...
or coding style blindly without understanding the reasons behind that design principle. Some examples are adding unnecessary comments to self-explanatory code, overzealous adherence to the conventions of a
programming paradigm
Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms.
Some paradigms are concerned mainly with implications for the execution model of the language, s ...
, or adding deletion code for objects that
garbage collection automatically collects.
Obsessive and redundant checks for null values or testing whether a collection is empty before iterating its values may be a sign of cargo cult programming. Such obsessive checks make the code less readable.
Origin

The term
cargo cult
A cargo cult is an indigenist millenarian belief system, in which adherents perform rituals which they believe will cause a more technologically advanced society to deliver goods.
Causes, beliefs, and practices
Cargo cults are marked by ...
as an
idiom
An idiom is a phrase or expression that typically presents a figurative, non-literal meaning attached to the phrase; but some phrases become figurative idioms while retaining the literal meaning of the phrase. Categorized as formulaic language, ...
originally referred to aboriginal religions that grew up in the South Pacific after World War II. The practices of these groups centered on building elaborate mock-ups of airplanes and military landing strips in the hope of summoning the god-like beings who arrived in airplanes that had brought marvelous cargo during the war.
In recent decades, anthropology has distanced itself from the term "cargo cult," which is now seen as having been reductively applied to a lot of complicated and disparate social and religious movements that arose from the stress and trauma of colonialism, and sought to attain much more varied and amorphous goals—things like self-determination—than material cargo.
Use of the term in computer programming probably derives from
Richard Feynman
Richard Phillips Feynman (; May 11, 1918 – February 15, 1988) was an American theoretical physicist, known for his work in the path integral formulation of quantum mechanics, the theory of quantum electrodynamics, the physics of the superf ...
's characterization of certain practices as ''
cargo cult science''.
Cargo cult software engineering
A related term to cargo cult programming in
software engineering
Software engineering is a systematic engineering approach to software development.
A software engineer is a person who applies the principles of software engineering to design, develop, maintain, test, and evaluate computer software. The term ' ...
is ''cargo cult software engineering'', coined by
Steve McConnell
Steven C. McConnell is an author of software engineering textbooks such as ''Code Complete'', ''Rapid Development'', and ''Software Estimation''. He is cited as an expert in software engineering and project management.
Career
McConnell graduat ...
.
McConnell describes software development organizations that attempt to emulate more successful development houses, either by slavishly following a
software development process
In software engineering, a software development process is a process of dividing software development work into smaller, parallel, or sequential steps or sub-processes to improve design, product management. It is also known as a software deve ...
without understanding the reasoning behind it, or by attempting to emulate a commitment-oriented development approach (in which software developers devote large amounts of time and energy toward seeing their projects succeed) by mandating the long hours and unpaid overtime, while in successful companies these might instead be consequences of high motivation instead of causes of success.
In both cases, McConnell contends that competence ultimately determines whether a project succeeds or fails, regardless of the development approach taken; furthermore, he claims that incompetent "imposter organizations" (which merely imitate the ''form'' of successful software development organizations) are in fact engaging in what he calls ''cargo cult software engineering''.
See also
*
Copy and paste programming
*
Cargo cult science
*
Magical thinking
Magical thinking, or superstitious thinking, is the belief that unrelated events are causally connected despite the absence of any plausible causal link between them, particularly as a result of supernatural effects. Examples include the idea that ...
*
Magic (programming)
*
Voodoo programming
References
Further reading
*''Surely You're Joking, Mr. Feynman!'', Richard Feynman, W. W. Norton & Co, New York, 1985, . One of the chapters is the transcript of a 1974 Caltech commencement address, which contained the
coining of "
Cargo cult science".
Cargo Cult Science, by Richard P. Feynman Article based on his 1974
Caltech
The California Institute of Technology (branded as Caltech or CIT)The university itself only spells its short form as "Caltech"; the institution considers other spellings such a"Cal Tech" and "CalTech" incorrect. The institute is also occasional ...
Commencement address, with pictures, as originally published in ''Engineering and Science'', Volume 37:7, June 1974. Digitized version from Caltech Library, retrieved June 20, 2007
{{DEFAULTSORT:Cargo Cult Programming
Anti-patterns
Computer programming folklore
Software engineering folklore