foo and bar - Does it have any special meaning?

21

In most code examples in various languages, I see these two names for variables - foo and bar . Is there any special meaning for them?

    
asked by anonymous 10.07.2016 / 07:15

2 answers

19

The origin of the term foo is obscure. The connection to bar is usually regarded as a term used by American troops in World War II, from the acronym FUBAR meaning " Fucked Up Beyond All Repair " - What translating into Portuguese is the expression (pardon me the swear word) " Fucked beyond all the possible repair " - That is, broken / zapped in an unrecoverable way. However, this origin, although plausible, is considered uncertain.

The source " foo " alone is a bit old, but can be attributed to Smokey comics Stover that began to be published in 1935, comic in which the word "foo" was very important. The comic books were filled with absurd items, bizarre vehicles, many pieces and weird things whose work seemed to be improbable or impossible, and often simply went wrong. Many of these things had the syllable foo in the name. There were also several nonsense dialogues. Anyway, there was a lot of gambiarra there!

According to the creators of Smokey Stover , the word foo comes from Chinese and means "good luck". In Chinese, 福 (which can be transliterated as fu or foo ) means happiness. Foo can also come from the French feu (which means "fire"), and the protagonist of Smokey Stover was a firefighter who was said be a foo fighter rather than a firefighter .

In programming, the terms foo and bar began to appear around the 1960s, and also have obscure origin, although they have appeared together. The first confirmed apparition was in 1965, although they may be a bit older. They used to appear in very gambiar codes, or in things that were reused a great number of times in contexts and situations so different, that it is even difficult to name or define the purpose of such thing. This clearly refers to what happens in Smokey Stover and the acronym FUBAR -. One thing super confused, bizarre and strange as that is buzzing that can not be repaired

In summary, foo and bar are just generic names for gambiarras.

Information obtained mostly in wikipedia: link

    
10.07.2016 / 07:56
14

About the popular foo and bar , are English terms used extensively in programming to illustrate examples (names of variables, methods, functions, classes ...). Just this. There is no special meaning. By bringing it into Portuguese (mutatis mutandis), it is as if it were fulano or sicrano of the programming language, or x and y of mathematics.

Origin

There are plenty of theories about the origin of these terms. References:

Wikipedia - foobar .

RFC3092 - Etymology of "Foo"

Some definitions

Foo

  

An term used for unimportant variables in programming when the   programmer is too lazy to think of an actual name.

link

  

Used very generally as a sample name for absolutely anything, esp.         programs and files (scratch files).

link

Foobar

  

A common term found in unix / linux / bsd   fillers for a word. Or, you can use the less intense or childish   form of fubar. To run the program, simply cd to the directory you   installed it in like this: user @ localhost cd foo / bar

link

    
10.07.2016 / 07:26