Welcome to my little CS trivia series. Every week I will post a new trivia piece because it seems that my mind is made of pieces of knowledge that don't make one knowledgeable but certainly serve as a good conversation starter (or, killer).
Today's question is...
Where did the cursed 'foo' and 'bar' come from?!
Now, you may already tell that I do not love these two fellows. In fact, I am not alone: read Daniel Warren or Derek Shanks who also admit confusion over these nonsensical examples.
Tutorial after tutorial, I contained my frustration patiently as I thought that maybe there is a deeper meaning or story behind these good-for-nothing placeholders. Well...
FUBAR, in American army jargon, means "f—- up beyond repair". The word came into use during WW2, and in programming context in 1965 in an MIT journal.
Now, Wikipedia provides us with ideas on other equally useful placeholder names, such as:
foobar, foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, plugh, xyzzy, and thud
or, in the UK:
wibble, wobble, wubble, and flob
and then, French:
toto, tata, titi, tutu
I still prefer naming my examples in any relatable way that makes it easier to figure out what is happening in the code from from the get-go.
Top comments (11)
Thank you
I would never name my function toto, but when I must use dozens of console.log then it will be console.log("toto") ou console.log("coucou") "coucou" being "hello" in a familiar french.
And yeah I don't like foo and bar either. They confuse me more than anything else
Totally! I’m a huge advocate of naming your functions, objects and variables descriptively :)
Like many of us. How many articles on naming is there on dev.to ? probably a lot!
Which is why foo and bar should be banned. Good practices on naming right from the start and everywhere
I grew very frustrated recently with a documentation where they used “foo bar” a lot and started wondering where these nonsensical words came from 😓 maybe we should write an extension that replaces metasyntactic variables with ones that have some logical relationship to each other ¯_(ツ)_/¯
I was told by old-timers in WWII that
Fubar = f___ (or fouled) up beyond all repair.
That's what Gramps said. ;))
Well, at least foobar has some positive connotations for you 🙃
I use a lot of "blubb", "bla" and "schubidu" for prototyping :)
That does sound fun! ✨
Wibble, Wobble and Wubble sound like great names for functions. I might use those next time a have a triplet to write!
Yes! At least they are fun! But 'foo' and 'bar'?! I am very much not impressed 👎👎👎