
Foo, bar, baz, and foobar are placeholder names in programming. Developers use them in examples when the exact variable, function, class, file, or object name does not matter. The words help readers focus on the structure of the code instead of the business meaning of the names.
If you have seen code examples like foo(), bar, or baz, the author is usually saying: “this name is not the important part.” The important part is the pattern being demonstrated.
What Does Foobar Mean?
Foobar is a generic placeholder word used in programming, documentation, and technical examples. It normally does not refer to a real function, product, person, or system. It is a stand-in name.
Programmers often split foobar into related placeholder names:
| Placeholder | Common use |
|---|---|
foo | A sample function, variable, object, or first placeholder |
bar | A second placeholder, often paired with foo |
baz | A third placeholder when the example needs another name |
qux | A less common fourth placeholder |
So when someone asks what foobar means, the practical answer is simple: it means “some example thing whose real name does not matter here.”
What Are Foo, Bar, and Baz?
Foo, bar, and baz are neutral example names. They appear in tutorials, textbooks, API documentation, Stack Overflow answers, and quick demos because they carry almost no business meaning.
That lack of meaning is useful. If an example uses names like customer, invoice, or payment, the reader may start thinking about the domain. If the example uses foo, bar, and baz, the reader is more likely to focus on the programming concept.
Where Did Foo Bar Baz Come From?
The term foo is believed to have originated from “FUBAR”, a military slang term used during World War II, meaning:
- Fouled (or a more explicit version) Up Beyond All Recognition.
The word foo appeared in various wartime cartoons and comics, particularly in Bill Holman’s “Smokey Stover”, a comic strip that frequently used the phrase “Foo!” in a nonsensical manner. This may have contributed to the term being absorbed into programming culture.
As computing developed in the 1950s and 1960s, early programmers needed generic placeholder names for variables, functions, and other identifiers. Over time, foo became a familiar placeholder in programming culture.
From foo, additional names followed:
- bar: probably because it sounds like “foobar”
- baz: continuing the pattern
- qux, quux, corge, grault: less common, but sometimes used
How Programmers Use Foo, Bar, and Baz
These names are used when demonstrating code structure without focusing on specific real-world variable names. They serve the same function as “John Doe” in legal documents or “Acme Corp.” in business examples.
Here is a simple Python example:
def foo(x):
return x * 2
bar = 5
baz = foo(bar)
print(baz)
In this example, foo is just a sample function name. bar is a sample input value, and baz is a sample result. The names are not the lesson. The structure is.
Why Developers Use Placeholder Names
Developers use placeholder names because they make examples lighter and easier to scan:
- They avoid distraction. Readers focus on the structure of the example rather than interpreting a real-world meaning.
- They are widely recognized. Programmers around the world understand that
fooandbarare generic placeholders. - They are flexible. The names can represent functions, variables, objects, files, services, or almost anything else.
- They keep examples short. A tiny example can show the programming idea without carrying a full business story.
There is a trade-off, though. For beginner tutorials, meaningful names are often better. A name like total_price can be clearer than foo when the example is teaching real application logic. Placeholder names work best when the names themselves are not important.
Foo Bar Baz vs Alice and Bob
Foo, bar, and baz are common in general programming examples. Alice and Bob are more common in cryptography, networking, and security examples, where they usually represent people or systems communicating with each other.
I wrote about that related naming tradition in The Curious Case of Alice Bob and Friends.
Conclusion
The meaning of foo bar baz is less mysterious than it first looks. These words are programmer placeholders. They help explain code when the exact name of a function, variable, or object does not matter.
The tradition has roots in military slang, early computing culture, and developer habit. Today, it remains a small but recognizable part of programming language: practical, a little strange, and useful when the example matters more than the names.