Live data from Hacker News

What is the history of the use of "foo" and "bar" in source code examples? (2012)

softwareengineering.stackexchange.com

41–50 of 150 posts

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#41
post #3

In addition to the military-programming history of "foo", there's also a military-programming history for the variable naming convention of "alfa", "bravo", "charlie", "delta", etc. The naming convention is known as the NATO phonetic alphabet: https://en.wikipedia.org/wiki/NATO_phonetic_alphabet

In the 1940s, the Army used a phonetic alphabet starting Able, Baker, Charlie. My late father was on the first two postwar atomic bomb tests (the first after Trinity, and at Hiroshima, Nagasaki) which were Able and Baker.

Able was an air burst over Bikini (thus the name of the swimsuit).

Baker, the water burst, was the world's first atomic disaster; as a result of Baker, the third scheduled test Charlie was cancelled. My father died years later of colon cancer, perhaps not unrelated to contaminated air and water at the Eniwetok base afterwards.

FUBAR indeed.

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#42
post #3

In addition to the military-programming history of "foo", there's also a military-programming history for the variable naming convention of "alfa", "bravo", "charlie", "delta", etc. The naming convention is known as the NATO phonetic alphabet: https://en.wikipedia.org/wiki/NATO_phonetic_alphabet

NATO phonetic alphabet is used in all areas where you have to say letters over voice. One character variable names for temp or iterator values are everywhere in programming. But I've never ever encountered one spelled out as a full transcriptions of the NATO phonetic alphabet like alfa, bravo, charlie. Exception is alpha for probability/statistics.

> NATO phonetic alphabet is used in all areas where you have to say letters over voice.

Not all. Military definitely favors NATO, but there are other phonetic alphabets in use. In particular, at least in the US, fire/ems personnel (and sometimes also law enforcement) use alternatives. The one that goes Adam, Boy (or Baker), Charlie, David, Edward, Frank, ... is still widely used.

I've also known agencies to use a mix, like Adam, Baker, Charlie, Delta, ... (a law enforcement agency that I dispatched for back in the 1990's used this version).

Source: was a firefighter and 911 dispatcher in a previous life and still spend a lot of time monitoring fire/ems channels locally just to stay connected to that world.

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#43
For some reason, in Sweden, the word "gazonk" is common after "foo" and "bar". I've never been been able to figure out why.

Here's a variant:

https://developer.arm.com/documentation/dui0493/i/CHDFAGEE

> foo\bar\baz\gazonk\quux\bop

Some Erlang reference:

https://erlang.org/pipermail/erlang-questions/2009-January/0...

> 43> lists:keysearch(foo, 1, [3.14, {foo,bar} | gazonk]). > {value,{foo,bar}}

The GNU Emacs manual:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Li...

> (setq foo '(bar zot > gazonk))

https://www.epicroadtrips.us/2003/summer/nola/nola_offsite/F...:

> Gazonk is often used as an alternative for baz or as a fourth metasyntactic variable. Some early versions of the popular editor Emacs used gazonk.foo as a default filename.

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#44
post #15

Earlier quoted context omitted.

> They have absolutely no connection to the matter at hand. Since foo is often used before bar, you would think there is an ordering between the two but there doesn't have to be. They are hard to pronounce and easier to confuse. I couldn’t disagree more. The entire point is that the variables are disconnected from the matter at hand. They’re widely recognised as placeholders, single syllable, distinctly pronounced fr…

I would agree with the comment you're responding to, too often in tutorials or especially in off hand comments here, I find their usage to assume some common but unindicated convention or subtext and obscure the concept they're trying to convey.

They’re the programmer equivalent of ‘x’ and ‘y’ in mathematics — which programmers don’t use as generic variables because they’re used for “math” embedded in code such as coordinates or measurements.

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#45
post #12

Earlier quoted context omitted.

> they are hard to pronounce I’d find it hard to think of two words easier to pronounce— what do you mean by this?

Proof that for any little thing that existed, exists, or could ever exist in this universe, there will be a non-zero list of human beings unhappy with it. Until the end of humanity, at least...

I am unhappy with your characterisation of my natural human trait of having a preponderance for unhappiness with all possible outcomes.

Re: What is the history of the use of "foo" and "bar" in source code examples? (2012)

#47

It blows me away that "The Jargon File" is not required canon. Well, it can be anachronistic and old-school-nerd-bro coded, but there's some primal stuff in there http://catb.org/jargon/html/

maybe it's time for an update
Post reply on HN