foo and bar - Does it have any special meaning?

Asked

Viewed 4,666 times

25

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

2 answers

26


The origin of the term foo is obscure. The connection with bar is usually taken as a term used by American troops in World War II, coming from the acronym FUBAR which means "Fucked Up Beyond All Repair" - That translating into Portuguese is the expression (forgive me the swear) "Fucked beyond all [possible] repair" - That is, broken/mocked in an unrecoverable way. However, this origin, although plausible, is considered uncertain.

The origin of "foo" alone is a little older, but can be attributed to the comics Smokey Stover which began to be published in 1935, a comic book in which the word "foo" was very important. The comics were filled with absurd items, bizarre vehicles, many pieces and strange things whose operation seemed unlikely or impossible, and often simply went wrong. Many of these things had syllables foo in the name. There were also several meaningless dialogues. Anyway, there was a lot of commotion 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 may also originate in French Feu (meaning "fire"), being the protagonist of the Smokey Stover was a firefighter who claimed to be a foo Fighter instead of a Firefighter ("firefighter" in English).

In programming, the terms foo and bar began to appear around the 1960s, and also have obscure origins, although they appeared together. The first confirmed appearance was in 1965, although they may be somewhat older. They used to appear in rather common code, or in things that were reused a large number of times in such different contexts and situations, that it is even difficult to name or define the purpose of such a thing. This clearly refers to what happens on Smokey Stover and the acronym FUBAR - A super confusing, bizarre and strange thing that is so messed up that it can no longer be fixed.

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

Information obtained mostly in wikipedia: https://en.wikipedia.org/wiki/Foobar

  • When my English was more than basic I thought it meant "full bar".

16

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

Origin

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

Wikipedia - Foobar (EN).

RFC3092 - Etymology of "Foo" (EN)

Some definitions (from English)

Foo

An term used for unimportant variables in Programming when the Programmer is Too Lazy to think of an actual name.

http://www.urbandictionary.com/define.php?term=foo

Used very generally as a sample name for Absolutely Anything, esp. Programs and files (esp. Scratch files).

https://www.ietf.org/rfc/rfc3092.txt

Foobar

A common term found in Unix/linux/bsd program help pages as space Fillers for a word. Or, can be used as a 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

http://www.urbandictionary.com/define.php?term=foobar

  • 4

    Cool boss attention... mai num put in English not... the link even goes, but not the definition......

  • 1

    Quotation (in the yellow frame) is ipsis Litteris, that is, in the same terms. My answer is in the first paragraph. These are English terms, after all. But I edited to indicate in which language is the reference.

  • Excuse my curiosity, where can I find this information, about the yellow frame being "ipsis Litteris", or are you saying that in this specific case is this, I’m not questioning you, I just want to better understand the system of the site...

  • 1

    The yellow frame - at least here in the OS - is a quotation (block quote), that is, by definition, a way to bring to the text a mention to an external information, preserving the original text and quoting the source. As a transcription. I found this guide here. I tried to give the answer (at least my opinion) in Portuguese and then quote the original sources (in the absence of finding material in PT-BR). But PT-BR translations are always welcome, you’re right. Hugs

  • Vlw for having answered...soft hehe... is that I started reading I was in Portugal, when I started interested I turned gringo ... your answer is time... But in my opinion it would be better if the English had translated... Inda mais pq are the coolest parts of the story... This bar still goes far... I wanted to know too, like although they don’t have a meaning and maybe...I read something in a I remember where, that they have a connection with each other... that makes an analogy with the programming and functions of mathematics...I’ll look.. Vlw man does not take offense...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.