Why are many examples of functions called foo?

I often see in various literature, video tutorials, articles on the Internet, and so on that demonstrative functions and methods are called foo.

What does this mean ?

Author: 0xdb, 2016-08-14

2 answers

Most likely words foo, bar and baz were born in the comic Smokey Stover and Pogo in the late 30s of the 20th century (as @AnT correctly noted) and, due to their popularity, began to be used by techies from MIT

From the author of the comic:

What’s Foo? My uncle found this word engraved on the bottom of a jade statue in San Francisco’s China town. The word Foo means Good-Luck.


What is Foo? My uncle found this word engraved on the bottom of a jade figurine in the "China town" in San Francisco. And denotes (translated) it is "luck" or " good luck!".

Here is a very detailed and detailed answer to this question in the English version of StackOverflow. In this answer, there are people's memories of the use of words foo,bar,baz,foobar , who worked directly in Tech Model Railroad Club (abbreviated TRMC) or, somewhat later, just in the MIT circle in the 1960s and 1990s.

Also, in the popularization of these words, the military abbreviation FUBAR ("Fucked Up Beyond All Repair", which can be translated as "not subject to repair", which referred to military equipment, or "Fucked Up Beyond All Recognition" - it was about human victims who could not be identified), which appeared during the Second World War and was rumored to have been invented by a certain a private who was "sickened" by all sorts of military abbreviations.

Techies from the TRMC club at MIT used the word " FOO " to refer to situations where an emergency system shutdown was necessary. In the case when someone pressed one of the emergency switches on the system board, instead of the time, the inscription "FOO" appeared and therefore these switches were called "Foo switches". Later, this club began to use buttons with the captions " FOO " and " BAR "(already as a tribute traditions), and they were used in a variety of situations.

Subsequently, it was used in the IT world as "placeholders", that is, for naming variables/classes in cases where it is not important (for example, in examples) or when nothing better comes to mind.

P.S.: there is also an unconfirmed version that "FOOBAR" comes from the German "furchtbar" (terrible).

 77
Author: MaxU, 2020-10-27 11:36:56

In Russian, foo is translated as "something" or in the context of a function "some function". This is just a name-an example when you need to focus on the syntax of a function. Like "Hello world" for the first program in the programming language being studied.

 4
Author: cheops, 2016-08-14 20:49:28