Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of foo, bar, baz, etc

I've always wanted to know what the foo, bar, baz, etc... names mean.

Several times I've found these terms in scientific articles. Furthermore this terminology in some way serves as a standard for other exemplifications.

Does anyone know where these terms come from, and how to use them properly?

like image 741
Alvaro Joao Avatar asked Dec 10 '15 21:12

Alvaro Joao


People also ask

What does foo, bar, baz meaning?

Foo bar baz are placeholder names used in computer programming to fill in for unknown, flexible, or as-yet undecided variables, including events or processes. For example, when building code, one process might call up another, stated in computer jargon as “foo calls bar.”

Where did foo, bar, baz come from?

Both "foo" and "bar" (and even "baz") were well known in popular culture, especially from Smokey Stover and Pogo comics, which will have been read by many TMRC members. Also, it seems likely the military FUBAR contributed to their popularity.

What's after foo, bar, baz?

“Foo” and “bar,” along with “baz,” “qux,” and “quux,” in that order, followed less strictly by “corge,” “grault,” “garply,” “waldo,” “fred,” “plugh,” “xyzzy,” and “thud,” among others, are used as placeholder names in program code that may be sketched quickly and may be intended to be provisional, demonstrative, ...

Why are functions called foo and bar?

Foo and bar are simply arbitrary names for methods, classes, variables, etc. for when showing examples of programming syntax. They came from the word "fubar", an acronym for "effed up beyond all recognition".


2 Answers

While this question borders on being outside the scope of Stack Overflow, I highly recommend the Wikipedia article on the matter:

The History of Foobar

To give a quick preview:

The word foo originated as a nonsense word from the 1930s, the military term FUBAR emerged in the 1940s... The term foo fighter was used by Allied aircraft pilots in World War II to describe various UFOs or mysterious aerial phenomena. The first known use of the terms in print in a programming context appears in a 1965 edition of MIT's Tech Engineering News.

like image 114
Alex Johnson Avatar answered Nov 06 '22 10:11

Alex Johnson


The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. 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.

Foobar Wikipedia article

tldr;

Foo, bar, and other terms are used as placeholder names to demonstrate a concept. In real life, these values are usually substituted with more meaningful names that fit the context of your code.

like image 4
UnrealApex Avatar answered Nov 06 '22 11:11

UnrealApex