Live data from Hacker News

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

softwareengineering.stackexchange.com

1–10 of 150 posts

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

#2
"In World War One “Foo was here” was scrawled across camps occupied by the Australian Expeditionary Force. Generally assumed to have come from the acronym for Forward Observation Officer, veterans of that war may have brought the tradition with them into the next global conflict over two decades later" https://taskandpurpose.com/history/the-story-of-kilroy-and-w...

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

#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

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

#4
post #2

"In World War One “Foo was here” was scrawled across camps occupied by the Australian Expeditionary Force. Generally assumed to have come from the acronym for Forward Observation Officer, veterans of that war may have brought the tradition with them into the next global conflict over two decades later" https://taskandpurpose.com/history/the-story-of-kilroy-and-w...

[dead]

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

#5
I don't know the story of the entry of foo into the computer science lexicon, but it is the case that the early days of computers were populated with a fair number of military veterans because early computers were mostly used in military applications so that produced people with computer experience (not to mention the compulsory draft which meant that a large number of people would have military experience anyway).

FUBAR ("fucked up beyond all recognition") was supposedly a military slang phrase.

And the popular comic strip Smoky Stover starting in the 1930's used the word "Foo" wrt a firefighting character perhaps giving that spelling more currency.

this is the Foomobile from that comic https://duckduckgo.com/?t=ffab&q=Foomobile&iax=images&ia=ima...

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

#7
post #5

I don't know the story of the entry of foo into the computer science lexicon, but it is the case that the early days of computers were populated with a fair number of military veterans because early computers were mostly used in military applications so that produced people with computer experience (not to mention the compulsory draft which meant that a large number of people would have military experience anyway). F…

The missing link is 'FURCHTBAR'.

Smokey Stover started the meme of substituting 'foo' into words. 1930s german language classes turned furchtbar (frightful) into 'foo-bar'. The US military acronymized it into FUBAR. Apparently MIT adopted fu() and bar() as algebra placeholders.

I'm partial to the 1938 song WHAT THIS COUNTRY NEEDS IS FOO - https://m.youtube.com/watch?v=W2pljKyCgwc

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

#8
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.

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

#9
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

> "alfa", "bravo", "Charlie", "delta"

Bit offtopic: As well as general use, a lot of thesed are used to classify Soviet/Russien submarines from a NATO point of use.

Even more off topic:This is quite interesting (to me at last) in that NATO has used prefix schemes for bombers, fighters etc. (for example Bear (bomber), Fishbed (fighter)) rather than their makers names. As far as I know, in WW2 the Germans always referred to RAF fighters by their RAF names.

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

#10
I understand that these variables have a rich and long history, but if you have ever heard a professor or anybody else say "foo" in lecture you will understand why I detest them.

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.

Whenever I give an example I use variable names that actually make sense and are related to the example. I'm glad that I have been fortunate to not see "foo" and "bar" anywhere in all of the code I've seen in recent memory.

Post reply on HN