yosefm has asked for the wisdom of the Perl Monks concerning the following question:

Maybe it's just because I'm not an american, but there are a few key words whose meaning I sought much but found nothing (I also try Super Search but you would guess what I got in a minute).

The words that I can't find the meaning of are "foo", "bar", and "baz" (and a few variations thereof). Can anyone enlighten me?

edited: Mon Jun 23 02:48:50 2003 by jeffa - title change (was: A cultural gap?)

Replies are listed 'Best First'.
Re: Origin of 'foo', 'bar', et al?
by benn (Vicar) on Jun 18, 2003 at 11:17 UTC
    They're just nonsense words commonly used when you need a "generic" name for something - a variable or a function, say. foo has a lot of info on the history of this, as has the Jargon File.

    Cheers, Ben.

Re: Origin of 'foo', 'bar', et al?
by Maclir (Curate) on Jun 18, 2003 at 12:49 UTC
    Generally, when someone is writing a piece of code to demonstrate something, they will choose meaningless variable names, simply because the name is not important, but the logic of the code is.

    I believe the origin of the words date back to a World War 2 US army expression "fubar" - f**ed up beyond all recognition - and hence we get two names, "foo" and "bar". Baz just jumped in the jeep and came along for the ride.

Re: Origin of 'foo', 'bar', et al?
by sauoq (Abbot) on Jun 18, 2003 at 17:35 UTC

    A lengthy report on the "Etymology of Foo" has been published as rfc3092.

    Although it is likely that FUBAR helped bring "bar" into use as the second metasyntactic¹ variable, "foo" existed prior to WWII. It's first known recorded use was in the Smokey Stover comic strip by Bill Holman, but it also showed up in a Warner Brothers cartoon and Pogo by Walt Kelly.

    1. They are called "metasyntactic variables" because they are used as variables for variables in code examples.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Origin of 'foo', 'bar', et al?
by talexb (Chancellor) on Jun 18, 2003 at 16:23 UTC

    As already mentioned, 'foo' and 'bar' come from FUBAR, an Americanization that seemed popular during World War II. Apparently the British were already using U/S for marking 'unserviceable' equipment, but that didn't go down well with the United States. I've also remember seeing 'NFG' on bad EPROM chips when I started working at Motorola in the summer of 1981.

    My pal Bob from Burlington once told me that 'foo' came from 'for once only' -- as in, something that you were going to build once and forget. I don't know where 'baz' came from, although I have a friend Mark who is nicknamed 'Baz' -- it's a short form of his last name.

    The word sometimes used as a fourth in that group is 'quux', and I'm curious about that one too -- it always makes me think of 'quincux', the name for an arrangement of five items placed in a cross (one in the middle, one above, one below, one to the left and one to the right). It's also a terrific book (so I'm told) written by a first time authour who wrote just a page each night without telling a soul .. but I digress .. as usual ..

    --t. alex
    Life is short: get busy!
Re: Origin of 'foo', 'bar', et al?
by fenonn (Chaplain) on Jun 18, 2003 at 17:42 UTC
    foo[everthing2.com] is the first in the sequence of metasyntactic variables[everything2.com] that were popularlized by MIT hackers.