Definition

foo (in software programming)

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. It can be helpful to use metasyntactic variables when creating sample code because programmers don't have to create unique names for each variable value. Nonsense placeholders make it easier to focus on the code's core concept and functional goal.

When defining a template for creating a new user command, for example, the syntax for the command could be written as:

Command foo (arg1, arg2)

The "foo" would mean "the name you give to this command." The "arg1" and "arg2" are arguments or information that will be defined and passed along with the command.

The term foo is not itself unique to the world of programming. The actual origin of the word, however, seems somewhat unclear. Eric Raymond, author of New Hacker Dictionary, observes that in Bill Holman's comic strip of the 1930-50 era, "Smokey Stover," the letters "F-O-O" commonly appeared, unexplained and as a kind of running gag on license plates, in picture frames and on the backs of sandwich board signs. There is also evidence that using the term foo derives from the World War II-era phrase FUBAR, as it is not unusual to see "foo" and "bar" both used as metasyntactic variables alongside each other, as shown below:

int max(int foo, int bar)
{
   int result;
 if (foo > bar)
   result = foo;
 else
   result = bar;
 return result;
}

Although foo is considered a canonical metasyntactic variable, Raymond notes that these variable names can vary based on geography. He lists qux, waldo, fred, xyzzy, and thud among others that are occasionally used. Fred, barney, and wombat seem common in the U.K., while toto, tata, titi and tutu are reportedly used by the French. Blarg and wibble are often used in New Zealand.

This was last updated in July 2016

Continue Reading About foo (in software programming)

Dig Deeper on XML and XML schema

PRO+

Content

Find more PRO+ content and other member only offers, here.

Related Discussions

Margaret Rouse asks:

Do you regularly use foo?

0  Responses So Far

Join the Discussion

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close