Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.


foo,bar,baz are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to indicate the author is showcasing a non-specific implementation of code. As this q+a reveals they are classified as metasyntactic variables.

While the history of these words seems to be rooted in over 50+ years of usage I can't find any resources studying their effectiveness.


Rather than take it a face value that their ubiquity is evidence for the effectiveness I'm wondering if there is evidence about the impact on linguistic comprehension.

To clarify, I know that foo is understood as signifying pseudo-code, but I'm referring to comprehension of what the pseudo-code means.


I have re-read the FAQ many times and before I get accused of being chatty I'm not trying to elicit a discussion, I'm not looking for personal anecdotes, I'm asking a question that is relevant to the programming community at large though it's on the edge of our concerns. I realize that there may be not anything published in this area but in case there is it'd be helpful to know in either case.

share|improve this question

closed as off-topic by gnat, MichaelT, GlenH7, Rob Y, Kilian Foth Jan 5 at 12:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, MichaelT, GlenH7, Rob Y, Kilian Foth
If this question can be reworded to fit the rules in the help center, please edit the question.

You don't need a study for this, just some common sense. foo, bar and baz are intended for syntactic demonstrations, where context doesn't matter. If you need context, as in result = repository.getCustomer(id), foo = bar(baz) is clearly going to be inadequate. –  Robert Harvey Jan 23 '13 at 0:45
Good question! The origins are widely discussed in this question: programmers.stackexchange.com/questions/69788/… but none of the answers explore their effectiveness for use in example code. –  Jay Elston Jan 23 '13 at 1:08
Then my sense is perhaps uncommon because I've never appreciated the second level of abstraction required. var dog = new Dog or var myVar = new MyClass are way more transparent in my book. –  Mark Fox Jan 24 '13 at 4:14

1 Answer 1

Foobar is effective at keeping the reader focused on the point you are trying to illustrate. It prevents their mind from going off on tangents.

//demonstration of the "dot" syntax
new Foo().bar().baz();


//demonstration of the "dot" syntax
new FireTruck().honkHorn().measureDecibals();

The firetruck example fills your mind with fire trucks. You may even want to argue with the instructor that measureDecibals() is not be a behavior of a horn honking. You may have a good point, but it is a tangent and not relevant to the dot syntax which is being illustrated.

FYI. Little known fact. Foobar is the phonic spelling of the FUBAR acronym. F***ed up beyond all recognition.

share|improve this answer
Little known according to...? –  Amy Blankenship Jan 23 '13 at 3:44
I've always thought 'foo' and 'bar' FUBARed example code. Hence my curiosity. –  Mark Fox Jan 24 '13 at 4:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.