Why do people use Foo?You’ve probably seen people using the word foo while writing a computer program. Probably not, but I’ve seen professionals, teachers, my classmates and buddies writing foo in their C, C++ and Java programs. I wondered and asked them why they used that word in their program. And they replied, just as they’ve seen others using it for a test.

Consider the below example of a C program:

// Program to add four determined integers
int foo(int a, int b, int c, int d);
int main() {
int result;
result = foo(12, 15, 24, 61);
}
int foo(int a, int b, int c, int d) {
return a+b+c+d;
}

Actually, words like foo, qux, foobar etc. are placeholder names, sometimes called as Meta-syntactic elements which are used just to demonstrate a concept in computer related documentation, regardless of any relationship with the program objective. They have no proper or actual meaning. In simple words, meta-syntactic elements are used just to demonstrate or test a concept or program.

As available on Wikipedia.Org:

In computer science, programmers use metasyntactic variables to describe a placeholder name or an alias term commonly used to denote the subject matter under discussion or an arbitrary member of a class of things under discussion. The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, which is often useful when creating or teaching examples of an algorithm. The word foo is the principal example.

A “standard list of metasyntactic variables used in syntax examples” often used in the United States is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud. The word foo occurs in over 330 RFCs and bar occurs in over 290. Wibble, wobble, wubble and flob are often used in the UK.

The word foo is the most popular among other meta-syntactic variables used by people. Not only in programming, it has also been used by people for important subjects: just like $foo, the name of Perl programming magazine and Foo Camp, an Annual hacker convention.