foo / bar

lore

programming

The canonical placeholder names in programming examples, used when the specific name does not matter.

"foo" and "bar" are metasyntactic variables: stand-ins that let an example focus on structure rather than naming. Their history is documented in RFC 3092, which traces the pairing to MIT and to the wartime slang FUBAR. When you need a third and fourth, "baz" and "qux" follow.

Foo and bar are the placeholder names every programmer reaches for, and their history is genuinely contested. The most cited derivation runs through FUBAR, the military acronym, though foo appears independently in American cartoons of the 1930s well before that usage spread, and the Jargon File treats the connection as probable rather than settled.

Their function matters more than their etymology. A placeholder name has to be obviously meaningless, so that nobody reading an example mistakes it for something significant, and foo has the useful property of carrying no domain associations at all. RFC 3092 exists specifically to document the terms, which is a fair indication of how deep into the culture they run.

The practical argument against them is worth making anyway. In documentation, foo and bar are cognitive overhead: a reader has to hold two arbitrary tokens in memory while following the logic, where names like user and order carry their own meaning and free attention for the actual point. Placeholders are honest in a language specification and lazy in a tutorial, and knowing which document you are writing decides which to use.

Also known as: foo-bar, foo, bar, metasyntactic variable

All glossary entries