If you’ve ever learned a programming language, chances are your first program printed two cheerful words:
Hello, World!
It’s become a rite of passage—like a programmer’s handshake. But why those words? Who started it? And what’s up with other classic programming terms like foo, bar, and baz?
Let’s trace the surprisingly human history behind these famous placeholders.
Why beginners print anything at all
When you’re learning a new language, you need a tiny program that:
- is easy to type,
- has an obvious result,
- proves your setup works (compiler/interpreter, editor, terminal, etc.),
- teaches the “shape” of the language (how to run code, how output works).
Printing a short message checks all those boxes. And “Hello, World!” is friendly, universal, and instantly recognizable.
So… who invented “Hello, World!”?
The modern origin: Brian Kernighan and C
The “Hello, World!” program became truly famous through the C programming language and the legendary book:
The C Programming Language (1978) by Brian Kernighan and Dennis Ritchie.
That book included a simple example program that printed:
hello, world
(Originally often shown in lowercase, depending on the edition and style.)
Because the book became the C bible, the example spread everywhere. And since C influenced many later languages, the tradition came along for the ride.
Earlier roots: it existed before C
Even though C made it iconic, Kernighan had used similar examples earlier. One widely cited predecessor appears in documentation for the language B (an ancestor of C), and related examples existed in older teaching materials.
Brian Kernighan also wrote a tutorial for BCPL in the early 1970s that printed a variant of the phrase. So the idea was already in the air—C just made it famous.
Why “Hello, World!” specifically?
Because it’s perfect for a first program:
- It’s positive. It feels like the computer is greeting you.
- It’s language-neutral. No math knowledge required.
- It’s obvious when it works. You see the exact output.
- It’s short. Minimal distraction from syntax.
Over time, it became more than a test—it became a tradition.
“Hello, World!” as a cultural signal
Today, “Hello, World!” does more than print text. It silently communicates:
- “This is the simplest possible working program.”
- “We’ve confirmed the toolchain is alive.”
- “We’re at the beginning of learning something new.”
That’s why you see it in everything from web frameworks to embedded devices to GPU tutorials.
What about foo and bar?
If “Hello, World!” is the classic first output, then foo and bar are the classic “stand-in” names programmers use when the real name doesn’t matter yet.
You’ll see them in examples like:
function foo(x) returns bar
or
foo = 10
bar = foo + 5
These are called metasyntactic variables—a fancy way of saying:
“These names are placeholders. Don’t overthink them.”
Where did foo and bar come from?
The exact path is a bit messy (language evolves in the wild), but the general story goes like this:
- “foo” appears in early 20th-century pop culture and cartoons as a nonsense word.
- “foobar” became popular in tech and military slang, possibly influenced by FUBAR (“Fouled Up Beyond All Recognition”), a WWII-era expression.
- Over time, programmers adopted foo, bar, and then added more placeholders in sequence: baz, qux, etc.
In short: they’re weird on purpose, so you don’t confuse them with meaningful names.
Other classic programming placeholder words (and why they exist)
Here are a few you’ll run into often:
baz, qux, quux
These are basically the “extended universe” of foo and bar. When you need three, four, or five placeholder names, you keep going.
spam and eggs
Popularized by a Monty Python sketch. Used in examples, especially when demonstrating lists, filtering, or text processing. Also tied to why “spam” means unwanted messages online.
Alice and Bob (and Carol, Dave…)
Common in cryptography, networking, and security examples—characters in a story problem. These names make abstract concepts easier to follow.
lorem ipsum
Used as placeholder text in design and web development. Not programming-specific, but you’ll see it everywhere in UI mockups and HTML templates.
Why programmers keep using these traditions
Because they’re simple, shared, and instantly recognizable. When you see:
- Hello, World! → you know it’s a first-step example
- foo/bar/baz → you know names don’t matter here
- Alice/Bob → you know it’s a scenario with roles
These words save time and reduce confusion—ironically by being intentionally meaningless.
Closing thought
“Hello, World!” stuck around because it captures a tiny, joyful moment: your first successful conversation with a new machine in a new language. And foo/bar exist for the opposite reason—so you can focus on the idea, not the label.
If you want, I can also add a short “Hello, World!” timeline (BCPL → B → C → modern languages) or include a fun list of “Hello, World!” examples across popular languages in the same blog style.
