Meaning of foo, bar, baz, etc
Asked Answered
J

2

39

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?

Jat answered 10/12, 2015 at 21:27 Comment(10)
Ask and thy shall recieve; tools.ietf.org/html/rfc3092Paramo
N.B. foo bar, foo baz, are acceptable but do not combine two foos in polite company (NSFW).Perplexed
that's awesome!! A rfc!! Thanks!Jat
@limelights you can answer the questionJat
No, it's fine. It's just a link. If someone else feels compelled but I think we got the answer we deserved.Paramo
Whenever I hear the use of "foo", "bar", or "baz", I lose respect for the presenter. Unlike the compilers of yesteryear that encouraged the use of short variable names (such as a1, a2, and a3) to save space, modern compilers support long and highly descriptive names, so there's little excuse to perpetuate this cryptic, over-used convention. And when you consider the meaning behind the FUBAR acronym, the "foo/bar" similarity IMHO makes its continued citation a crude and immature practice.Illation
@Illation thanks for your input!Jat
@Illation Of course, the variables shouldn't be used in real code projects, but as variable names for illustration purposes, foo is a much better choice than metasyntactic_variable_whos_exact_identity_is_unimportant. Then again I sometimes enjoy crude and immature jokes -- there's no accounting for taste.Microhenry
@spinup: You don’t need to go from “foo” to a multi-syllabic, multi-word variable name. “Foo” is not a better choice than, say, “interest_rate” or “yield” as “foo” tells you nothing about what’s being illustrated.Illation
@Illation I don't think I quite explained what I meant by "illustration purposes" -- if what's being illustrated has to do with, say, economics, then your examples may be good choices. But what I meant was, when illustrating a general programming concept, a short variable name such as foo can be a good choice, because it doesn't distract from the coding concept you're trying to illustrate. Of course you may argue that one can just use a or something for those situations, which is fair enough; again, a matter of taste.Microhenry
B
14

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.

Basaltware answered 10/12, 2015 at 21:41 Comment(0)
T
6

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.

Tiresome answered 22/6, 2021 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.