Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Possible Duplicate:
Using “Foo” and “Bar” in examples

I discovered that in many examples of code i various books/questions/answers/tutorials the word Foo is used to name functions, interfaces, classes, properties, variables etc.

  • It is a special name, or is simple to name something in 3 letters, and why Foo?
share|improve this question

migrated from stackoverflow.com Dec 5 '11 at 1:34

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Glenn Nelson, tcrosley, World Engineer, Morons, Mark Trapp Dec 5 '11 at 3:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

catb.org/jargon/html/F/foo.html –  Mat Dec 4 '11 at 20:05
This is a duplicate of programmers.stackexchange.com/q/69788/6586 –  Bryan Oakley Dec 5 '11 at 1:38
Probably got popularized by text-book writers lacking creative inspiration. ;) –  Marlon Dec 5 '11 at 2:39

3 Answers 3

Excerpted from the Jargon File:

When ‘foo’ is used in connection with ‘bar’ it has generally traced to the WWII-era Army slang acronym FUBAR (‘Fucked Up Beyond All Repair’ or ‘Fucked Up Beyond All Recognition’), later modified to foobar. Early versions of the Jargon File interpreted this change as a post-war bowdlerization, but it it now seems more likely that FUBAR was itself a derivative of ‘foo’ perhaps influenced by German furchtbar (terrible) — ‘foobar’ may actually have been the original form.

For, it seems, the word ‘foo’ itself had an immediate prewar history in comic strips and cartoons. The earliest documented uses were in the Smokey Stover comic strip published from about 1930 to about 1952. Bill Holman, the author of the strip, filled it with odd jokes and personal contrivances, including other nonsense phrases such as “Notary Sojac” and “1506 nix nix”. The word “foo” frequently appeared on license plates of cars, in nonsense sayings in the background of some frames (such as “He who foos last foos best” or “Many smoke but foo men chew”), and Holman had Smokey say “Where there's foo, there's fire”.

If this sort of etymological study is of interest to you, there's a vast wellspring more of it at the link.

But what's known for certain is that the modern usage of foo (and bar, and much other modern computer nonsense jargon) is first documented as appearing at MIT in the late 1950s. Which bits of jargon the MIT engineers/students picked up from elsewhere (say, from a popular comic strip from six or seven years earlier), and which they invented themselves is much less well-documented. Hints about a history pre-dating the MIT Tech Model Railroad Club are intriguing, but are also mostly supposition and anecdotes.

share|improve this answer
+1 for the research. –  Kris Dec 5 '11 at 10:01

Pardon my french, but you asked.....

foo is the first part of foobar.

foobar = FUBAR = Fucked up beyond all recognition.

Yes. That's what it means. The foobar spelling is based on the sound based phonics. How did it become popular in programming examples??? That I don't know.

share|improve this answer

It's a component of 'FooBar', a commonly used placeholder name and metasyntatic variable.

From the Wikipedia Article:

The terms foobar /ˈfʊːbɑː/, fubar, or foo, bar, baz and qux (alternatively quux) are sometimes used as placeholder names (also referred to as metasyntactic variables) in computer programming or computer-related documentation. They have been used to name entities such as variables, functions, and commands whose purpose is unimportant and serve only to demonstrate a concept. The words themselves have no meaning in this usage. Foobar is sometimes used alone; foo, bar, and baz are sometimes used in that order, when multiple entities are needed.

share|improve this answer