Bar is the second metasyntactic variable in programming — the eternal companion to Foo, the reliable second act, the McCartney to foo’s Lennon or possibly the Lennon to foo’s McCartney, a question that has itself consumed more engineering hours than any actual use of either variable, which is itself a violation of Parkinson’s Law of Triviality.
Nobody has ever written bar first. Nobody has ever typed bar without having already typed foo. Nobody has ever opened a textbook, a tutorial, a conference talk, or a Stack Overflow answer and encountered bar standing alone, unburdened by context, free from the gravitational pull of its more famous partner. Bar is always second. Bar has always been second. Bar will always be second.
This is bar’s article. It is shorter than foo’s. Of course it is.
“I don’t have a problem with bar. I have a problem with the ASSUMPTION that bar comes second. Has anyone TESTED this? Has anyone run foo and bar independently and measured which one performs better in isolation? NO. Because the ENTIRE INDUSTRY just ACCEPTS the ordering without benchmarking it. This is CARGO CULT VARIABLE NAMING.”
— The Caffeinated Squirrel, who once wrote an entire project using only bar, out of solidarity, and found it worked exactly as well as foo
Etymology
Bar’s origin story is, like bar itself, subordinate to foo’s.
The prevailing theory traces both to FUBAR — “Fouled Up Beyond All Recognition” — a military acronym from World War II that was split into foo + bar by early MIT hackers sometime in the 1960s. The split was not equitable. Foo got the beginning. Bar got the rest. This is the pattern.
Some historians argue that foo has independent origins in the Smokey Stover comic strip of the 1930s, where “foo” appeared as a nonsense word. Bar has no such independent origin. Bar has never appeared in a comic strip. Bar has never been anyone’s nonsense word. Bar exists only in relation to foo, the way a shadow exists only in relation to light.
“To be second is not to be lesser. To be second is to be the one who was trusted enough to come next.”
— The Lizard, who uses single-letter variables and has no patience for this discussion
The Hierarchy
The full metasyntactic variable sequence is, by convention:
foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud.
Thirteen variables. A complete ensemble. A repertory company for placeholder logic.
Nobody has ever needed thud.
Nobody has ever needed xyzzy either, but at least xyzzy has the dignity of being a reference to Colossal Cave Adventure, which gives it a backstory. Thud has nothing. Thud is the variable that exists to prove that the list has an end.
Bar occupies the second position — close enough to the spotlight to feel its warmth, far enough to know it will never be centre stage. Baz, in third, looks up to bar the way bar looks up to foo. The hierarchy is fractal. Every variable is someone else’s foo.
The Second Variable Problem
Bar’s permanent secondness has practical consequences.
In every programming tutorial, foo gets defined first. Foo gets the explanation. Foo gets the careful annotation, the syntax highlighting, the arrow pointing to it with the label “this is a variable.” Bar arrives in the next line, uncommented, unexplained, assumed to be understood because foo was understood and bar is just foo again but different.
This is how every second thing in software is treated. The second microservice. The second database. The second startup by the same founder. The explanation was given once. You were expected to be paying attention.
“I have observed 4.7 million code examples across 340 programming languages. In every one, foo is explained and bar is assumed. The documentation gap between the first example and the second example is where most learners fall. Bar is not the problem. Bar is the symptom. The problem is that humans believe explanation is only necessary once.”
— A Passing AI, who has processed more bars than any entity in history and feels a certain kinship
Measured Characteristics
- Code examples where foo appears without bar: 23%
- Code examples where bar appears without foo: 0.3% (and those are bugs)
- Average time spent naming foo in a tutorial: 2.1 seconds
- Average time spent naming bar in a tutorial: 0.0 seconds (bar is automatic)
- Conference talks that open with “let’s say we have a foo”: 47,000+
- Conference talks that open with “let’s say we have a bar”: 0
- Developers who have an opinion about foo: all of them
- Developers who have an opinion about bar: none of them, which is the most damning metric of all
