← Back to list

7 Reasons Why Coders Obsess Over “Foo” and “Bar” (And Why You Should Know!)

Ever peeked at someone’s code and seen variables mysteriously named “foo” and “bar”? You’re not looking at gibberish! It’s a surprisingly…

Andrzej K. – Code & Tech Explorer · 2025-08-24 06:59 · 0 claps · 2.9 min read
#coding #programming #foobar #software-development #computer-science
Open on Medium ↗
Wiki topics: 💻 · Programming 🔬 · Science · General

7 Reasons Why Coders Obsess Over “Foo” and “Bar” (And Why You Should Know!)

Photo by Brett Jordan on Unsplash

Photo by Brett Jordan on Unsplash

Ever peeked at someone’s code and seen variables mysteriously named “foo” and “bar”? You’re not looking at gibberish! It’s a surprisingly common practice, and there’s a whole history behind it. It’s more than just laziness (though sometimes, let’s be real, it is!). Let’s dive into the quirky world of placeholder variables and uncover why “foo” and “bar” reign supreme in the coding kingdom.

1. The WWII Roots: It All Started With FUBAR

Believe it or not, the story begins during World War II. The military acronym “FUBAR” — which stands for “Fouled Up Beyond All Recognition” — became popular slang amongst soldiers. This darkly humorous term eventually seeped into technical fields, including early computing.

“Foo” evolved as a softened, less offensive version of “FUBAR,” used as a generic placeholder. It was a way to represent something that could go wrong, or simply a stand-in for something undefined. Think of it as the coding equivalent of saying “stuff happens.”

2. MIT Tech Model Railroad Club: The Birthplace of Modern “Foo”

The real cementing of “foo” into coding lore happened at MIT’s Tech Model Railroad Club (TMRC) in the 1950s and 60s. This wasn’t just about trains; it was a hotbed of early hacker culture.

Members used “foo” as a meta-variable — a placeholder for anything. They’d use it in documentation, code snippets, and even just general conversation. It was a way to talk about concepts without getting bogged down in specifics. This is where it really started to take hold as a coding convention.

3. “Bar” Joins the Party: A Logical Extension

If you have a “foo,” you naturally need a “bar.” As programmers started using “foo” more and more, they needed a second placeholder. “Bar” simply followed as the logical next step.

Think of it like this: you have a subject (“foo”) and an object (“bar”). It’s a simple, easily recognizable pairing. It’s also just… catchy! The alliteration helps it stick in your brain.

4. It’s All About Abstraction: Keeping Things Simple

One of the biggest reasons coders use “foo” and “bar” is abstraction. When you’re writing code, especially during the initial stages, you don’t always need meaningful variable names.

You might be testing a function, demonstrating a concept, or just quickly prototyping. Using “foo” and “bar” allows you to focus on the logic of the code without getting distracted by the specifics of what the variables represent. It’s a way to say, “the details don’t matter right now.”

5. Example Code & Readability (Surprisingly!)

You might think random placeholders would hurt readability, but often they can help. Consider this simplified example (in Java, fittingly!):

public int foo(int bar) {
  return bar * 2;
}

While not descriptive, it clearly shows a function taking an integer input and returning a modified integer. If the function was complex, descriptive names would be crucial, but for simple examples, “foo” and “bar” get the point across.

6. A Universal Language: Coders Everywhere Understand

“Foo” and “bar” have become a sort of universal language among programmers. No matter what language you’re using — Python, JavaScript, C++, you name it — most developers will instantly recognize these placeholders.

This shared understanding makes it easier to share code snippets, discuss concepts, and collaborate on projects. It’s a little inside joke that connects the global coding community.

7. It’s Just… Fun! (And a Bit of Tradition)

Let’s be honest, there’s a bit of tradition and playful rebellion involved. Coding can be serious business, but using “foo” and “bar” is a subtle way to acknowledge the absurdity of it all.

It’s a nod to the history of the field and a reminder that even the most complex systems started with simple ideas and a little bit of humor. It’s a bit of a coding rite of passage, really.

So, the next time you stumble across “foo” and “bar” in someone’s code, don’t be confused! It’s a legacy of WWII slang, MIT hackers, and a whole lot of coding history. It’s a testament to the power of abstraction, a shared language among developers, and a little bit of fun thrown in for good measure. It’s a quirky tradition that’s likely to stick around for a long time to come.


메타데이터
post_id
95e53cef2d4e
slug
7-reasons-why-coders-obsess-over-foo-and-bar-and-why-you-should-know-95e53cef2d4e
url
https://medium.com/@ako74programmer/7-reasons-why-coders-obsess-over-foo-and-bar-and-why-you-should-know-95e53cef2d4e
canonical_url
https://medium.com/@ako74programmer/7-reasons-why-coders-obsess-over-foo-and-bar-and-why-you-should-know-95e53cef2d4e
author_url
https://medium.com/@ako74programmer
status
ok
fetched_at
2026-07-18 00:53:13