News for hackers. Stuff that matters.
Re:What is the history of the use of "foo" and "bar" in sour... by Max_Ehrlich on Saturday October 05, 2024 @05:08PM (#41752925)
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 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.

Re:What is the history of the use of "foo" and "bar" in sour... by maccard on Saturday October 05, 2024 @05:23PM (#41753027)
> 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.

Re:What is the history of the use of "foo" and "bar" in sour... by hedvig23 on Saturday October 05, 2024 @05:51PM (#41753215)
I would agree with the comment you're responding to, too often in tutorials or especially in off hand comments here, I find their usage to assume some common but unindicated convention or subtext and obscure the concept they're trying to convey.
Re:What is the history of the use of "foo" and "bar" in sour... by jiggawatts on Saturday October 05, 2024 @06:27PM (#41753379)
They’re the programmer equivalent of ‘x’ and ‘y’ in mathematics — which programmers don’t use as generic variables because they’re used for “math” embedded in code such as coordinates or measurements.
Re:What is the history of the use of "foo" and "bar" in sour... by thaumasiotes on Saturday October 05, 2024 @06:46PM (#41753470)
> 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 sour... by maccard on Monday October 07, 2024 @04:09PM (#41770427)
Show me a phrase and I'll show you a language it doesn't work in.
Re:What is the history of the use of "foo" and "bar" in sour... by thaumasiotes on Monday October 07, 2024 @04:39PM (#41770781)
Is there a language that identifies "ta" and "pa"?
Re:What is the history of the use of "foo" and "bar" in sour... by bshacklett on Sunday October 06, 2024 @07:43PM (#41761342)
It’s the same idea that drove Lorem Ipsum for type setting placeholders.
Re:What is the history of the use of "foo" and "bar" in sour... by urbandw311er on Saturday October 05, 2024 @05:11PM (#41752944)
> they are hard to pronounce

I’d find it hard to think of two words easier to pronounce— what do you mean by this?

Re:What is the history of the use of "foo" and "bar" in sour... by rmbyrro on Saturday October 05, 2024 @05:15PM (#41752967)
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...
Re:What is the history of the use of "foo" and "bar" in sour... by jiggawatts on Saturday October 05, 2024 @06:28PM (#41753383)
I am unhappy with your characterisation of my natural human trait of having a preponderance for unhappiness with all possible outcomes.
Re:What is the history of the use of "foo" and "bar" in sour... by rmbyrro on Sunday October 06, 2024 @08:55AM (#41756827)
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 sour... by douglee650 on Saturday October 05, 2024 @05:45PM (#41753183)
It's like business schools using "widget" for the product and "Acme" for the company — they are dealing in concepts, not absolutes
Re:What is the history of the use of "foo" and "bar" in sour... by Brian_K_White on Saturday October 05, 2024 @05:29PM (#41753080)
The very reason you say something like foo is to avoid using any specific example that might actually mean something and confuse the listener into thinking it matters and focussing on some irrelevant detail instead of the actual concept being illustrated.

You detest that someone says "thing" instead of "house" or something?

"...so you take a thing-"

"what thing?"

"It doesn't matter. It might be anything. So you-"

"A car?"

Come on man.

Re:What is the history of the use of "foo" and "bar" in sour... by thiht on Saturday October 05, 2024 @06:02PM (#41753262)
When I started to learn programming (by myself), I had a really hard time understanding what foo and bar were and what they meant in various tutorials and blogs. I was already trying to learn the syntax and programming concepts, throwing some unknowns words in the mix did NOT help. For some time I thought foo had special meaning in PHP, or that it meant something in English (not my first language, and I was much less proficient in English at ~14 than I am today).

Using foo bar baz qux is lazy when you can easily find countless examples.

Re:What is the history of the use of "foo" and "bar" in sour... by Dylan16807 on Saturday October 05, 2024 @09:50PM (#41754141)
If they used 'thing' and 'stuff' would you be happier? A B C? What would you suggest as a generic variable name?

> Using foo bar baz qux is lazy when you can easily find countless examples.

Countless examples of what?

Re:What is the history of the use of "foo" and "bar" in sour... by thiht on Monday October 07, 2024 @07:58AM (#41765123)
> If they used 'thing' and 'stuff' would you be happier? A B C?

Yes to both.

> Countless examples of what?

Anything illustrative. Like libraries/books, cars, whatever. Anything is better than foo/bar