I've seen a lot of people using "foo" as method names or class names in java on Stackoverflow and other things. What's foo? Is it just a generic name for any method, class, etc. or does it actually mean anything? And why foo? Is it only for java or do people use it for other languages too?
Foo (pronounced FOO) is a term used by programmers as a placeholder for a value that can change, depending on conditions or on information passed to the program. Foo and other words like it are formally known as metasyntactic variables.
According to an Internet Engineering Task Force RFC, the word FOO originated as a nonsense word with its earliest documented use in the 1930s comic Smokey Stover by Bill Holman.
foo is used as a place-holder name, usually in example code to signify that the object being named, or the choice of name, is not part of the crux of the example. foo is often followed by bar , baz , and even bundy , if more than one such name is needed. Wikipedia calls these names Metasyntactic Variables.
In the world of computer programming, "foo" and "bar" are commonly used as generic examples of the names of files, users, programs, classes, hosts, etc. Thus, you will frequently encounter them in manual (man) pages, syntax descriptions, and other computer documentation.
It's traditionally used for just a random name. Some other common ones are:
The supposed origin of foo and bar is that "FUBAR" was WWII slang for F***ed Up Beyond All Recognition. FUBAR => FOOBAR => Foo and Bar.
There isn't really a compelling reason to choose it besides the fact that no language reserves the word foo
and that it's easy enough to type/read.
foo
is a term used to represent something without you getting too attached to the meaning. I could say object a
in its place or literally anything else.
see examples 1 or 4 here: http://www.urbandictionary.com/define.php?term=foo
It's a generic name for a thing, using in computer science in general. Etymologically, "foo" is the first syllable of "FUBAR", which is an acronym for "**ed Up Beyond All Recognition/Recovery".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With