Live data from Hacker News

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

softwareengineering.stackexchange.com

111–120 of 150 posts

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

#112
post #55

Earlier quoted context omitted.

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.

How does it not answer the question "why would women avoid fu over foo"? I thought it was clear that "fu" means "fuck up" or even "fuck you", a sexual swear word, while "foo" means nothing at all.

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

#113

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…

For people, who (like me) don't know US military slang, FUBAR apparently means 'Fucked/Fouled Up Beyond All/Any Repair/Recognition/Reason' according to Wikipedia.

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

#114
post #12

Earlier quoted context omitted.

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.

Proof that the statement is an axiom. And the fact that it's an axiom also falls under the axiomatic principle of guaranteed human unhappiness.

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

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

No "supposedly" about it. FUBAR is still in common use. As is RHIP (Rank Hath Its Privileges) and BOHICA (Bend Over Here It Comes Again)

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

#117

Earlier quoted context omitted.

On a related note, we all know the story from WW2 where Bastogne was surrounded by the Wehrmacht, and the Wehrmacht sent a note to General McAuliffe suggesting he surrender. He returned with a note that simply said "nuts". I simply did not believe than an American GI ever said "nuts". So, I asked my dad (WW2 veteran). He said he briefly worked for the General, and asked him what he actually wrote. The General laughed…

I doubt this story very much. It's well documented that McAuliffe rarely used profanity, and it's similarly well documented, including by the US Army official historian, that the official reply was indeed "nuts". https://history.stackexchange.com/questions/40063/what-did-g...

Whether or not it's true, I think it's a pretty good story because it aligns BAR with "Beyond All Recognition", which is exactly the point of a metasyntactic variable: to be so separate that that context is unrecognizable.

Obfuscating the context is what F's it Up. Usually that's a problematic thing, but in the case of foo and bar, the F'ed Up version is maybe better.

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

#119
post #46

foobar should die out. myvariable, mystring, myfunction etc. are better in every way.

Prefixing things with My is so Windows 95... In place of foo and bar I prefer to go with stuff like one() two() three(), or a() b() c(), timeless classics that need no explanation.

The point is that tyoe is an EXTREMELY vaulable information and if you are explaining code to someone it is very helpful to clearly see what are keywords, what are arbitrary variable names, and what are the types of the variables. For example if you show me a programming language where there is a list object and you write list.one(), I don't know if list is a variable or a keyword, and I don't know if one is a variable or a keyword. Much better to write mylist.one() if one is a default function, or mylist.myfirstelement() otherwise etc.

I mean everyone knows using descriptive variable names is good practice, but then in a coding tutorial it is somehow fine to use foo, bar, a, b, c? That makes things clearer for someone who understands all the types and the syntax, and wants to see the structure algorithm more clearly. It hurts someone trying to learn the language.

Post reply on HN