Live data from Hacker News

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

softwareengineering.stackexchange.com

51–60 of 150 posts

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

#51

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/

http://catb.org/jargon/html/F/foobar.html

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

#52

MIT AI Lab back in the 1960s published technical reports containing program code. The military slang 'FUBAR' f'ed up beyond all recognition, was in the student and professor engineering vocabulary. The tradition became to use 'fu' and 'bar' as nominal function names, in same manner as X and Y were nominal variables. Often in the MIT technical reports, one would see 'x = fu(y)' or 'y > bar(z)' and so forth. If you kne…

Why would women in particular object to "fu" and not "foo"?

Because they are subject both to sexual harassment and to higher expectations, including "professionalism" (not using profanity at the workplace in this specific case).

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

#53
post #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: h…

> For some reason, in Sweden, the word "gazonk" is common after "foo" and "bar".

That doesn't look like it's a potentially Swedish word.

It does resemble an English one: https://en.wiktionary.org/wiki/gazongas

(For whatever reason, wiktionary insists on defining "gazongas" only as "the plural form of 'gazonga'", but the word "gazonga" cannot be used at all; much as with "scissors" or "pants", only the plural form exists.)

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

#55

Earlier quoted context omitted.

Why would women in particular object to "fu" and not "foo"?

Because they are subject both to sexual harassment and to higher expectations, including "professionalism" (not using profanity at the workplace in this specific case).

This isn't an answer to the question.

Smug responses like this just means you don't actually have a point.

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

#56
post #29

Earlier quoted context omitted.

Of course it is. What's not clear is what that has to do with women.

I imagine that, due to the societal expectations historically placed on women, they’ve typically had to be “the adult in the room.” Contrast this with men historically being able to get away with acting childishly (or worse). So when terminology used in the workplace is particularly vulgar, it would follow that women would take more issue with it than men.

This is a sexist statement

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

#57
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…

The change from able... to alpha... was a NATO thing. some European countries don't use the "a" in "able", so it was changed to the "a" in "alpha"

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

#58
post #15

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 giv…

> 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…

> distinctly pronounced from each other

This isn't so much of an advantage for "bar" and "baz". Those sound pretty distinct to Americans, now, but "r" -> "z" is a known type of sound change, which implies that for some people they'll sound the same. "R" -> "s" is attested in Latin, presumably because "z" wasn't an option. (Latin fricatives don't have voicing distinctions.)

For an only slightly different current example, the second consonants in "virile" and "vision" are perceived as distinct in American English, but identical in Mandarin Chinese, which is why the sound is spelled as "r" in Hanyu Pinyin and as "j" in Wade-Giles.

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

#59

MIT AI Lab back in the 1960s published technical reports containing program code. The military slang 'FUBAR' f'ed up beyond all recognition, was in the student and professor engineering vocabulary. The tradition became to use 'fu' and 'bar' as nominal function names, in same manner as X and Y were nominal variables. Often in the MIT technical reports, one would see 'x = fu(y)' or 'y > bar(z)' and so forth. If you kne…

A few years later, perhaps with the welcome progress of more female faculty and students, textbooks changed the spelling, but not the pronunciation of the vulgar acronym 'fu' to 'foo'.

I was always told that fu became foo because it lined up nicely on screens and on paper, making the code easier to scan.

  foo = 1
  bar = 2
looks better than

  fu = 1
  bar = 2

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

#60
post #13

Earlier quoted context omitted.

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

Seems like that retelling comes from an IETF RFC: https://www.ietf.org/rfc/rfc3092.txt (Etymology of "Foo")

The date of the rfc is Apr 1st -- unclear how truthful it is.
Post reply on HN