Spaghetti Code

Noun · Hacker Culture · Origin: 1970

Definitions

  1. Source code with a tangled, incomprehensible control flow — typically featuring excessive goto statements, deep nesting, and no discernible structure. The kind of code where tracing execution feels like following a single strand of spaghetti through a bowl.

    In plain English: Code that's so messy and tangled that nobody can figure out what it does or how to change it without breaking something.

Origin Story

A pasta insult from the structured programming wars

In the 1960s and 1970s, the **structured programming movement** — championed by Edsger Dijkstra, who famously argued that GOTO statements were harmful — needed a vivid way to describe the tangled control flow they opposed. **Spaghetti code** was the perfect metaphor: code where execution jumps around so erratically that tracing the logic is like following a single strand through a plate of spaghetti.

The term appeared in print by the early 1970s and was widely used in structured programming debates. It specifically targeted code with excessive GOTO statements, which could make a program's control flow so convoluted that even the original author couldn't follow it a week later.

The food metaphor spawned an entire taxonomy: **ravioli code** (too many small, isolated pieces), **lasagna code** (too many layers), and **pizza code** (flat with everything mixed together). Spaghetti remains the most damning diagnosis — a codebase so tangled that refactoring it feels less like engineering and more like archaeology.

Coined by: Structured programming community

Context: Structured programming debates, early 1970s

Fun fact: Dijkstra's 1968 letter 'Go To Statement Considered Harmful' is one of the most influential papers in CS history. The editor, Niklaus Wirth, actually changed Dijkstra's original title to something more provocative — creating the 'Considered Harmful' meme that persists to this day.

Related Terms