Software development (and learning to code in general) tends to be a frustrating process. After sifting through tutorial after tutorial, you’re almost certain to bump into a few terms that live in infamy in the field: “foo” and “bar.” Today, I’ll quickly share their history as well as some perspectives with folks who are still holding onto them.
Table of Contents
Modern Usage
If you’ve looked at any programming tutorials online, there’s an incredibly high chance that you’ve seen variables with strange names like “foo” and “bar.” No doubt these are terrible variable names, yet you’ll still see them all over the place.
In my case, I most recently saw “foo” being used in a practice exam for a course I teach. The choice of “foo” was deliberately meant to obscure the purpose of a piece of code as students were expected to figure it out without context clues (like variable names). Regardless, many students asked me “what the heck is foo?”
After seeing my students just as confused as I was the first time I saw it, I figured I’d share my best guess at the origins of the terms as well as what other folks have said around the internet.
A Borrowed Phrase?
Most of the time when you see “foo” in a tutorial, “bar” is not far behind. When slapped together, you get “foobar,” which is awfully similar to the phrase: fubar (i.e., fucked up beyond all recognition). In other words, the use of “foo” and “bar” seems like a clever joke hidden in code (i.e., this code is junk). Interesting to see it then in educational materials.
Regardless, the connection between “foobar” and “fubar” turns out to have some truth—at least according to Jim Ferrans. But is that the whole story?
According to some other folks, “foo” might actually predate “fubar,” with evidence pointing back to the 1930s or earlier. In fact, RFC, which tracks various technical documents, has a document that covers the etymology of “foo.” In their document, they argue that “fubar” may only have influenced the popularity of “foobar” and that “foobar” may even be the original term. Specifically, they point to a variety of comics and cartoons that contain the term “foo” prior to World War 2.
And, RFC aren’t the only keepers of knowledge. Another user, known as Hugo, shared some resources that refer to the term “foo” from 1930s university documents.
Should We Continue to Use Foo?
Having gone through the existing literature on the origins of “foobar,” I don’t think this is a subject that I can really contribute to in a meaningful way. As a result, I’ll share what I think is the best reference for learning more about the history of these terms (i.e., RFC3092).
Instead, I want to take a moment to reflect on “foo” and it’s use in modern tutorials. Given the fact that most folks who see and use “foo” have no understanding of it’s origins, it’s probably time to let the term die out. While its intended use is as a throwaway placeholder, most folks just find it more confusing. Instead, I might advocate for being more explicit when making placeholders—like literally using the term “placeholder.” And certainly I’m not the only one who hates its use:
- Stop Using Foo Bar!
- Extensive Use of Foo Bar in Examples
- Please Stop Using “foo” And “bar”
- “Foo”, “Bar” – Does This Actually Help Anyone – Ever?
- Against ‘foo’ (And ‘bar’ Too)
Although, be careful in some of those posts above. A lot of folks seem to really love “foo” and “bar.”
At any rate, that’s about all I had time for today. It’s the holidays after all, and I should probably be spending time with my family. Of course, if you’re reading this with some free time, check out some of these related posts:
Otherwise, take care! And as always, feel free to help grow the site.
Recent Posts
It seems I'm in my mentorship arc because I can't stop writing about how to support students. Today, we're going to tackle one of the more heartbreaking concerns that students have: the idea that...
For my friends in the humanities, it probably comes as a surprise, but our STEM programs are really allergic to open-ended projects. As a result, I figured I would pitch them today.