Live data from Hacker News

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

softwareengineering.stackexchange.com

101–110 of 150 posts

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

#101

I have always felt that the foo/bar demo/example snippets have held me back in comprehending code, because there was no reasonable logic to it. It just means nothing to me, other than the FUBAR reference others have mentioned. I personally, and professionally, think it’s a horrible convention.

I understand your perspective, and have felt similarly at times. OTOH I appreciate having some culture and some fun things in our field and teaching materials that would otherwise be pushed out by being 100% reasonable and logical all the time.

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

#102
post #86

Earlier quoted context omitted.

There was a concept of treating women with respect.

That's a non-sequitur. There are plenty of other words that start with 'fu-'. It's also a loanword from Chinese. And even if not, I haven't heard anyone describe the coinage 'fupa' as offensive.

To the downvoters: I said I don't find merit in the suggestion that using 'fu' (or 'foo' as a function name) would be considered to constitute profanity. When learning programming, I simply learned 'foo, 'bar' and 'baz' as silly-sounding example function names. I didn't make any connection from 'foo' in the CS context to 'fubar' in US military slang till over a decade later.

(Neglecting that there weren't many women in CS in the 1960s. I don't even see that the word-fragment would have been considered offensive in civilian context, esp. to non-US speakers of English)

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

#103

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…

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

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

#104

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…

> Often in the MIT technical reports, one would see 'x = fu(y)' or 'y > bar(z)'

Hmm, "fu"? The decades confound my memory, but I don't immediately recall seeing a "fu" there? Before the "foo" of AIM-127a[1] in 1967 and MIT-LCS-TR-032[2] in 1966, there's still a decade of AI Memos, and couple of years of TRs. DSpace finds at least some "fu"s... lots of ocr fragments. The AITR-220 '64 hit is ocr fragment. My search-fu tonight wasn't up to being exhaustive (spot checks were all fragments). And also, OCR could be missing older "fu"s. But I didn't quickly find a real "fu".

A foo-bar-baz-quux in MIT-LCS-TR-365[3] in 1986.

One can start on the CSAIL collections page[4] and explore.

[1] "FOO" in abstract of AIM-127a LISP Linkage Feature: Incorporating MIDAS into PDP-6 LISP https://dspace.mit.edu/handle/1721.1/6136 [2] "Thus if FOO has the definition (LAMBDA (X Y) [alpha]), and the user calls SYSTEM1 with NAME= FOO, ADVICE= [beta], WHERE= BEFORE" on page 43 of MIT-LCS-TR-032 Pilot: A Step Towards Man-Computer Symbiosis https://dspace.mit.edu/handle/1721.1/149354 [3] "if the back trace is: FOO [1] ID World: An Environment for the Development of a Dataflow Programs Written in ID MIT-LCS-TR-365 https://dspace.mit.edu/handle/1721.1/149633 [4] https://dspace.mit.edu/handle/1721.1/5458

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

#105

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/

> old-school-nerd-bro I'm trying to maintain that the nerds of yore and the bros* who invaded in the 2010s are different groups -- in which case "old-school nerd bro" would be a contradiction in terms -- but alas "bro" has simply come to mean "male", and, to the English majors writing the newspaper articles, "they all look the same". So maybe I need to give up. * etymology: "tech bro", in analogy with "finance bro",…

You are correct. Don’t give up!

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

#106

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

People who rarely use profanity means they do use it, and when they do, they do it for effect. Certainly, a demand that he surrender Bastogne would justify profanity in a forceful response.

> including by the US Army official historian

An official US Army historian's job is to make the US Army look good.

As we are all painfully aware these days, the accounts of newspapers are rarely accurate, and often outright fabrications. Why would WW2 accounts be any different?

I doubt McAuliffe would want to besmirch his record after the war, had nothing to gain by contraindicating it, and would be content to let it stand.

My father was a carefully honest man, and was never known by me to lie. He held his tongue until after McAuliffe passed away. He also told me some family secrets after all involved had passed, and asked me to keep them to myself until after he died, which I did.

It never occurred to me to ask him to write down that story, and now it's too late.

I know my evidence is hearsay and inadmissible in court. You're free to draw your own conclusions.

P.S. I was once personally involved in an incident that made the local TV news. There was nothing political about it, but each of the three local news channels got essentially all the basic facts about it wrong. But that is the "record" of the event. It pretty much soured me on the veracity of news reports.

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

#107

Earlier quoted context omitted.

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

People who rarely use profanity means they do use it, and when they do, they do it for effect. Certainly, a demand that he surrender Bastogne would justify profanity in a forceful response. > including by the US Army official historian An official US Army historian's job is to make the US Army look good. As we are all painfully aware these days, the accounts of newspapers are rarely accurate, and often outright fabri…

Well Walter, ask yourself why Kinnard, who was in the room at the time and Harper, who delivered the message, and Premetz, the non-commissioned medic who translated it for the Germans, all give repeated official accounts and interviews that contradict the account of your father, who by your own admission merely "worked for the general briefly".

Is it all a grand conspiracy to protect the good name and reputation of McAuliffe?

I'll say no more.

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

#108

Earlier quoted context omitted.

People who rarely use profanity means they do use it, and when they do, they do it for effect. Certainly, a demand that he surrender Bastogne would justify profanity in a forceful response. > including by the US Army official historian An official US Army historian's job is to make the US Army look good. As we are all painfully aware these days, the accounts of newspapers are rarely accurate, and often outright fabri…

Well Walter, ask yourself why Kinnard, who was in the room at the time and Harper, who delivered the message, and Premetz, the non-commissioned medic who translated it for the Germans, all give repeated official accounts and interviews that contradict the account of your father, who by your own admission merely "worked for the general briefly". Is it all a grand conspiracy to protect the good name and reputation of M…

My father had a first hand account from McAuliffe, like the other three, and had no reason whatsoever to misrepresent it.

> Is it all a grand conspiracy to protect the good name and reputation of McAuliffe?

A small conspiracy is not at all far-fetched. First off, it's an inconsequential thing. Secondly, if one of the three told the truth, then he'd be called a liar by the other two. Who needs that? If you're in the military, you don't get ahead by contradicting the narrative. (My dad found that out the hard way - he was punished more than once for not writing reports that fit the narrative.)

For a grand conspiracy, consider how long Biden's staff held out insisting that Biden was sharp as a tack and writing off contrary reports as disinformation.

The most compelling bit about my evidence is the frankly laughable idea that a GI would use the word "nuts".

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

#109

Earlier quoted context omitted.

Well Walter, ask yourself why Kinnard, who was in the room at the time and Harper, who delivered the message, and Premetz, the non-commissioned medic who translated it for the Germans, all give repeated official accounts and interviews that contradict the account of your father, who by your own admission merely "worked for the general briefly". Is it all a grand conspiracy to protect the good name and reputation of M…

My father had a first hand account from McAuliffe, like the other three, and had no reason whatsoever to misrepresent it. > Is it all a grand conspiracy to protect the good name and reputation of McAuliffe? A small conspiracy is not at all far-fetched. First off, it's an inconsequential thing. Secondly, if one of the three told the truth, then he'd be called a liar by the other two. Who needs that? If you're in the m…

P.S. I understand you have no particular reason to believe me, and if I were in your shoes I wouldn't, either.

If there is any takeaway here, it would be that historical accounts are always suspect. History is written by the victors, as they say.

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

#110
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.
Post reply on HN