235

I hope this qualifies as a programming question, as in any programming tutorial, you eventually come across 'foo' in the code examples. (yeah, right?)

what does 'foo' really mean?

If it is meant to mean nothing, when did it begin to be used so?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
prakash
  • 58,901
  • 25
  • 93
  • 115
  • The question linked in the previous comment has apparently been deleted. It is still available in the unofficial archive of deleted questions: http://stackoverflow.hewgill.com/questions/262/271.html . see also this related deleted question: http://stackoverflow.hewgill.com/questions/163/229.html – HugoRune Feb 01 '13 at 19:13

9 Answers9

139

See: RFC 3092: Etymology of "Foo", D. Eastlake 3rd et al.

Quoting only the relevant definitions from that RFC for brevity:

  1. Used very generally as a sample name for absolutely anything, esp. programs and files (esp. scratch files).
  1. First on the standard list of metasyntactic variables used in syntax examples (bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud). [JARGON]
Community
  • 1
  • 1
BCS
  • 75,627
  • 68
  • 187
  • 294
  • 5
    Mark Tomlin, look at the date in that RFC. – Windows programmer May 10 '10 at 05:17
  • 5
    RFC - "Request For Comments documents were invented by Steve Crocker in 1969 to help record unofficial notes on the development of the ARPANET. They have since become the official record for Internet specifications, protocols, procedures, and events". Source: [http://www.livinginternet.com](http://www.livinginternet.com/i/ia_rfc.htm) – ZygD Nov 29 '15 at 10:11
  • Why use the term "foo" when a more informative term (like "test" or "temp") could be used? Maybe it's one of those cultural things - programmers feel using old jargon like foo gives them "street cred". – RobertF Feb 12 '19 at 20:30
  • We're not here for brevity. The RFC also says "When used in connection with `bar' it is generally traced to the WW II era Army slang acronym FUBAR (`Fucked Up Beyond All Repair'), later modified to foobar." – Melinda Green Dec 14 '20 at 12:00
44

foo is used as a place-holder name, usually in example code to signify that the object being named, or the choice of name, is not part of the crux of the example. foo is often followed by bar, baz, and even bundy, if more than one such name is needed. Wikipedia calls these names Metasyntactic Variables. Python programmers supposedly use spam, eggs, ham, instead of foo, etc.

There are good uses of foo in SA.

I have also seen foo used when the programmer can't think of a meaningful name (as a substitute for tmp, say), but I consider that to be a misuse of foo.

Community
  • 1
  • 1
Will Harris
  • 21,597
  • 12
  • 64
  • 64
22

As definition of "Foo" has lot's of meanings:

  • bar, and baz are often compounded together to make such words as foobar, barbaz, and foobaz. www.nationmaster.com/encyclopedia/Metasyntactic-variable

  • Major concepts in CML, usually mapped directly onto XMLElements (to be discussed later). wwmm.ch.cam.ac.uk/blogs/cml/

  • Measurement of the total quantity of pasture in a paddock, expressed in kilograms of pasture dry matter per hectare (kg DM/ha) www.lifetimewool.com.au/glossary.aspx

  • Forward Observation Officer. An artillery officer who remained with infantry and tank battalions to set up observation posts in the front lines from which to observe enemy positions and radio the coordinates of targets to the guns further in the rear. members.fortunecity.com/lniven/definition.htm

  • is the first metasyntactic variable commonly used. It is sometimes combined with bar to make foobar. This suggests that foo may have originated with the World War II slang term fubar, as an acronym for fucked/fouled up beyond all recognition, although the Jargon File makes a pretty good case ... explanation-guide.info/meaning/Metasyntactic-variable.html

  • Foo is a metasyntactic variable used heavily in computer science to represent concepts abstractly and can be used to represent any part of a ... en.wikipedia.org/wiki/FOo

  • Foo is the world of dreams (no its not) in Obert Skye's Leven Thumps series. Although it has many original inhabitants, most of its current dwellers are from Reality, and are known as nits. ... en.wikipedia.org/wiki/Foo (place)

  • Also foo’. Representation of fool (foolish person), in a Mr. T accent en.wiktionary.org/wiki/foo

Resource: google

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
Lukas Šalkauskas
  • 14,191
  • 20
  • 61
  • 77
11

It's a metasyntactic variable.

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
10

foo = File or Object. It is used in place of an object variable or file name.

Deathstalker
  • 794
  • 10
  • 8
7

I think it's meant to mean nothing. The wiki says:

"Foo is commonly used with the metasyntactic variables bar and foobar."

GateKiller
  • 74,180
  • 73
  • 171
  • 204
3

The sound of the french fou, (like: amour fou) [crazy] written in english, would be foo, wouldn't it. Else furchtbar -> foobar -> foo, bar -> barfoo -> barfuß (barefoot). Just fou. A foot without teeth.

I agree with all, who mentioned it means: nothing interesting, just something, usually needed to complete a statement/expression.

user unknown
  • 35,537
  • 11
  • 75
  • 121
3

Among my colleagues, the meaning (or perhaps more accurately - the use) of the term "foo" has been to serve as a placeholder to represent an example for a name. Examples include, but not limited to, yourVariableName, yourObjectName, or yourColumnName.

Today, I avoid using "foo" and prefer using this type of named substitution for a couple of reasons.

  • In my earlier days, I originally found the use of "foo" as a placement in any example to represent something as f'd-up to be confusing. I wanted a working example, not something that was foobar.
  • Your results may vary, but I always, 100%, everytime, never-failed, got more follow-up questions about the meaning of the actual variable where "foo" was used.
Jimmy B
  • 31
  • 2
2

In my opinion every programmer has his or her own "words" that is used every time you need an arbitrary word when programming. For some people it's the first words from a childs song, for other it's names and for other its something completely different. Now for the programmer community there are these "words" as well, and these words are 'foo' and 'bar'. The use of this is that if you have to communicate publicly about programming you don't have to say that you would use arbitratry words, you would simply write 'foo' or 'bar' and every programmer knows that this is just arbitrary words.

khebbie
  • 2,490
  • 3
  • 31
  • 53
  • 2
    If "everybody" knows this, why are so many people asking about the meaning of "foo", "bar" and "foobar"? Prakash is not the first person to ask. IMO foo, bar and foobar are not intuitive, like a, b, c, tmp, X, Y, Z, var and func, which is why I think many pe – Anders Sandvig Sep 10 '08 at 12:07
  • Hm.. Is it just me, or is the rendering of long comments broken? Anyway, the rest was "... why I think many people find them distracting." – Anders Sandvig Sep 10 '08 at 12:08
  • 1
    Yeah, you exceeded your 300 characters limit for a comment ;) but thanks! – prakash Sep 11 '08 at 09:11
  • I am probably just tangled too deep in the developer community ;-) – khebbie Sep 12 '08 at 09:56
  • I found (and find) them distracting. Especially when first trying to decipher python, I took them to be far more meaningful than they are. Maybe a function, or some part of the syntax. Though I had the same issue with things like **kwargs. I instinctively try to memorise stuff like that. To the point of writing it down. Until someone told me "it doesn't matter what phrase you use, as long as you have the ** ". At least "kwargs" makes sense when you realise what it stands for. Stuff like "foo" is just confusingly 'mystical'. They feel like injokes for the sake of injokes. – OmikronWeapon May 05 '20 at 09:23