8 ms·
What is the history of the use of "foo" and "bar" in source code examples? (2012)
- mikewarot 2y agoNo zot? I don't remember where I picked them up. But it was always fubar and zot.
- temp0826 2y agoNever heard of zot, but baz
- DougMerritt 2y agoZot is (at least in part) from the old comic Wizard of Id and (by the same artist, Johnny Hart and Brant Parker) BC. It was the sound of a lightning bolt (natural or wizard-created). Reprint cover of "Ala Ka Zot!": https://m.media-amazon.com/images/I/61hytBWmsqL._SL1000_.jpg https://m.media-amazon.com/images/I/61hytBWmsqL._SL1000_.jpg
- helph67 2y ago"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-why-he-was-there/ https://taskandpurpose.com/history/the-story-of-kilroy-and-w...
- dangsux 2y ago[dead]
- jph 2y agoIn 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 https://en.wikipedia.org/wiki/NATO_phonetic_alphabet
- Cheer2171 2y agoNATO 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.
- g4zj 2y agoSome of them could potentially be a little confusing as well, such as "delta" in game development, "echo" in some networking contexts, or "uniform" in OpenGL shaders. I don't tend to use single-letter variable names outside of the standard `for(;;)` syntax, but if I did, I don't think I'd replace them in this way.
- mindcrime 2y ago> 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.
- dfox 2y agoLaw enforcement/EMS often have their own phonetic alphabets and it is not that uncommon to use two at once: one for call signs and second for the actual alphanumeric data (in theory, in practice it gets mixed up, but everybody still understands the meaning)
- fsckboy 2y agoI 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=images https://duckduckgo.com/?t=ffab&q=Foomobile&iax=images&ia=ima...
- ahazred8ta 2y agoThe 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 https://m.youtube.com/watch?v=W2pljKyCgwc
- chiph 2y agoNo "supposedly" about it. FUBAR is still in common use. As is RHIP (Rank Hath Its Privileges) and BOHICA (Bend Over Here It Comes Again)
- baggy_trough 2y agoNo love for quxx?
- Max_Ehrlich 2y agoI 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.
- urbandw311er 2y ago> they are hard to pronounce I’d find it hard to think of two words easier to pronounce— what do you mean by this?
- rmbyrro 2y agoProof 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...
- jiggawatts 2y agoI am unhappy with your characterisation of my natural human trait of having a preponderance for unhappiness with all possible outcomes.
- rmbyrro 2y agoProof that the statement is an axiom. And the fact that it's an axiom also falls under the axiomatic principle of guaranteed human unhappiness.
- maccard 2y ago> 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 from each other, and have an implied ordering.
- symbolicAGI 2y agoMIT 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 knew, you knew. 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'. Again, if you knew, you knew. And now you all know.
- stackghost 2y agoWhy would women in particular object to "fu" and not "foo"?
- the_gipsy 2y agoBecause they are subject both to sexual harassment and to higher expectations, including "professionalism" (not using profanity at the workplace in this specific case).
- b59831 2y agoThis isn't an answer to the question. Smug responses like this just means you don't actually have a point.
- the_gipsy 2y agoHow 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.
- jckahn 2y agoIs it not clear what “f” and “u” is short for?
- deleted 2y ago[deleted]
- douglee650 2y agoIt 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/
- fragmede 2y agomaybe it's time for an update
- d0mine 2y agohttp://catb.org/jargon/html/F/foobar.html http://catb.org/jargon/html/F/foobar.html
- FooBarBizBazz 2y ago> 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", which originated because fraternity brothers from top schools used to go into finance, but then migrated into Tech around '08. Associated stereotypically with developed pectorals and polo shirts with popped collars. Close to the "Chad" archetype, but with some light granola/yoga overtones.
- IggleSniggle 2y agoI've been the same way but I think it's time to give up; the language has moved on, and it's only a very specific age bracket that recognizes the distinction. Graybeard means something different now too. It's okay though. It's not important and doesn't need to be maintained; it was just another form of gate-keeping... the early "nerd-bro" practically required the distinction as a form of identity reclamation in a culture that disparaged their puny interests in computing. We should celebrate that that particular shield is no longer needed, and thus that gatekeeping is no longer needed for ego-survival, either.
- dang 2y agoSurprisingly little. Others? Foo Bar came from model trains at MIT - https://news.ycombinator.com/item?id=41069963 https://news.ycombinator.com/item?id=41069963 - July 2024 (2 comments) The Origin of Foo and Bar - https://news.ycombinator.com/item?id=14030938 https://news.ycombinator.com/item?id=14030938 - April 2017 (1 comment) Kind of related but not really: foo@bar.com - https://news.ycombinator.com/item?id=24605949 https://news.ycombinator.com/item?id=24605949 - Sept 2020 (281 comments) The Foo at bar.com - https://news.ycombinator.com/item?id=10108287 https://news.ycombinator.com/item?id=10108287 - Aug 2015 (29 comments) foo@bar.com is a real email address - https://news.ycombinator.com/item?id=3263021 https://news.ycombinator.com/item?id=3263021 - Nov 2011 (91 comments)
- lysace 2y agoFor 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 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/041215.html 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/Lisp-Indent.html 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/FQ_en.wikipedia.org/en.wikipedia.org/wiki/Metasyntactic_variable.html 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.
- thaumasiotes 2y ago> 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 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.)
- cool_dude85 2y agoI don't agree with the thing about the singular "gazonga". Just like if you were to say a boob or a tit, I think a gazonga would be understood by anyone.
- thaumasiotes 2y agoWhat can be understood is a separate question from what it's possible to say. Here's a common type of utterance from a foreign student of English: *Where you heard this? There's no risk of being misunderstood, but that doesn't mean it's possible to phrase a question in English this way. What would you understand if someone asked you for "the scissor"?
- golol 2y agofoobar should die out. myvariable, mystring, myfunction etc. are better in every way.
- fragmede 2y agothey're longer, for one, so no
- jonathrg 2y agoHow about x, y, f?
- creativenolo 2y agoIs it not foo() and bar()? MyVariable and… ?
- smolder 2y agoPrefixing 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.
- golol 2y agoThe 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.
- gU9x3u8XmQNG 2y agoI 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.
- LouisSayers 2y agoI agree, to me it's always looked like baby speak. Reading about "FUBAR" makes it even worse.
- marssaxman 2y agoIt's supposed to mean nothing; that's the point. You use "foo" and "bar" (and "baz" and "qux", etc) when the names of the things in your example do not matter. It's the same way you'd see examples featuring "x", "y", and "z" when learning algebra: maybe your textbook also has story problems, but most of the examples will simply show an equation in terms of x, y, and maybe z, without pretending that those abstractions refer to anything concrete.
- jamincan 2y agoI think meaningless abstractions are fine to a point, but when you have a less trivial example, it can make it harder to keep track of the relationship of different things. For example, you might see something like trait Foo { fn frobulate() } struct Bar; struct Baz; impl Foo for Bar { fn frobulate() { // TODO } } fn qux<T: Foo>(...) It's ends up being too abstract. A more concrete example would help clarify the relationship of the different elements.
- callc 2y agoI 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.
- Yhippa 2y agoBut where did “baz” come from?
- 1vuio0pswjnm7 2y agoAnd quux.
- wodenokoto 2y agoSo I guess it is lost to history, but how did a military cynicism sneak into programming? And judging from the origin stories posted it came from failed military campaigns and then was somehow spread to the broader programming community through MIT. There’s a few steps there missing. But on the other hand, a lot of posters in TFA writes “if you knew you knew”, and maybe most people who spread this didn’t know. I mean, I’ve used it without a second thought plenty of times just because. It might be as simple as an ex military professor writing it and students picking it up as “this is how we talk” with basically no one knowing what they are talking about.
- wiihack 2y agoI remember when I started coding in java many years ago. Everywhere I saw foo classes and I had absolutely no idea what they mean :)
- sflefties 2y ago[dead]
- electricant 2y agoThe reference to the Monty Python spam sketch is gold :D
- asimpletune 2y agoDoes anyone have any other successors to foo and bar? Mine have always been bis buz baz, but I don't know if they're canonical or if I just made up the next words in the sequence.
- deleted 2y ago[deleted]
- rchard2scout 2y agoAccording to the Jargon File, (http://www.catb.org/~esr/jargon/html/F/foo.html http://www.catb.org/~esr/jargon/html/F/foo.html) the successors are baz, qux, quux, etc.
- hinkley 2y agoI don’t know how I started this but I’ve used the following since before I had a beard: foo/bar/baz/bing/bang/bong Once in a while I’ll throw “biz” in after baz. I suspect the bar/baz pairing felt like alliteration to me and I extended it. I’ve never used it in production code of course, but I have in tests. For string interpolation or parsing tests you tend to need a lot of variables or values and you don’t care what the variable means you just want the right ones placed in or extracted from the correct spots. In particular if the rest of the data looks legit and the bits sunstituted looks like gibberish, I find it makes the red tests’ failure message quicker to read.
- SeanLuke 2y agoThe top response is wrong. So of course it was locked and made impossible to downgrade or correct. If this isn't a canonical Stack Overflow example I don't know what is.
- DesiLurker 2y agoI though fubar was short for fu*ked up beyond all recognition. that'd have turned into foo-bar.
- m0d0nne11 2y ago"Foo" is the bowdlerized rendering of FU and I have always been deeply disappointed seeing it used by otherwise intelligent, clueful people.
- rurban 2y agoIn short: FUBAR, the military expression, stands for "fucked up beyond all recognition"