Foobar

From Wikipedia, the free encyclopedia
  (Redirected from Foo bar)
Jump to: navigation, search
Not to be confused with FUBAR.
"Foo" redirects here. For other uses, see Foo (disambiguation).

The terms foobar (/ˈfbɑːr/), or foo and others are used as placeholder names (also referred to as metasyntactic variables) in computer programming or computer-related documentation.[1] They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept.

History and etymology[edit]

Smokey Stover driving a "foomobile".

The etymology of foo is obscure. When used in connection with bar it is generally traced to the World War II military slang FUBAR, later bowdlerised to foobar.[2] The use of the word foo on its own was used earlier. Between about 1930 and 1952 it appeared in the comic Smokey Stover by Bill Holman who stated that he used the word due to having seen it on bottom of a jade Chinese figurine in Chinatown, San Francisco, meaning "good luck".[3] This may be related to the Chinese word fu ("福", sometimes transliterated foo), which can mean happiness.[2]

The use of foo in a programming context is generally credited to the Tech Model Railroad Club (TMRC) of MIT from circa 1960.[1] However, the precise relationship of these terms is not known with certainty, and several anecdotal theories have been advanced to identify them.

The first known use of the terms in print in a programming context appears in a 1965 edition of MIT's Tech Engineering News.[4] Foobar may have come about as a result of the pre-existing "Foo" being conjoined with "bar" an addition borrowed from the military's FUBAR. The use of foo in hacker and eventually in programming context may have begun in MIT's Tech Model Railroad Club (TMRC). In the complex model system, there were scram switches located at numerous places around the room that could be thrown if something undesirable was about to occur, such as a train going full-bore at an obstruction. Another feature of the system was a digital clock on the dispatch board. When someone hit a scram switch, the clock stopped and the display was replaced with the word "FOO"; at TMRC the scram switches are, therefore, called "Foo switches". Because of this, an entry in the 1959 Dictionary of the TMRC Language went something like this: "FOO: The first syllable of the misquoted sacred chant phrase 'foo mane padme hum.' Our first obligation is to keep the foo counters turning."[5] One book[which?] describing the MIT train room describes two buttons by the door: labeled "foo" and "bar". These were general purpose buttons and were often re-purposed for whatever fun idea the MIT hackers had at the time, hence the adoption of foo and bar as general purpose variable names. An entry in the Abridged Dictionary of the TMRC Language states:[6]

Multiflush: stop-all-trains-button. Next best thing to the red door button. Also called FOO. Displays "FOO" on the clock when used.

The term foobar was propagated through computer science circles in the 1960s and early 1970s by system manuals from Digital Equipment Corporation.[citation needed] Foobar was also used as a variable name in the Fortran code of Colossal Cave Adventure (1977 Crowther and Woods version). The variable FOOBAR was used to contain the player's progress in saying the magic phrase "Fee Fie Foe Foo".

Example use in code[edit]

In this Hello World code sample, foo and bar are used to illustrate string concatenation:

/* C code */

#include <stdio.h>

int main()
{
   const char *foo = "Hello";
   const char *bar = "World!";
   fprintf(stdout, "%s %s\n", foo, bar);

   return 0;
}

Examples in language[edit]

See also[edit]

References[edit]

  1. ^ a b Eastlake, D; Manros, C; Raymond, E. "Etymology of "Foo"". The Internet Engineering Task Force. Retrieved 17 April 2016. 
  2. ^ a b "the definition of foo". Dictionary.com. Retrieved 2016-05-09. 
  3. ^ "The History of Bill Holman". www.smokey-stover.com. Retrieved 2016-04-17. 
  4. ^ Tech Engineering News, Volume 47. Massachusetts Institute of Technology. 1965. p. 63. Further, it is possible to search for an effective address; e.g., if an instruction such as "add 1 foo" were used, specifying indirect addressing thru location "foo", and location "foo" contained the address of location "foobar", than an effective word search for "foobar" would find location "foo" and the location containing the "add" instruction as well. 
  5. ^ "Computer Dictionary Online". , computer-dictionary-online.org
  6. ^ "Abridged Dictionary of the TMRC Language". MIT. 
  7. ^ Microsoft ploy to block Sun exposed, news.com
  8. ^ "Google Foobar: How searching the web earned a software graduate a job at Google". International Business Times UK. 2015-08-27. Retrieved 2016-05-09. 
  9. ^ tmdb.eu. "Trademark FUBAR registered by Stanley Black & Decker, Inc. at OHIM". tmdb.eu. Retrieved 2016-05-10. 

External links[edit]