Is it useful to use foo, bar, baz in examples?

Please remember I said;

My point was that this is the sort of response that foo/bar/baz is meant to forestall. Had you taken it at all seriously, I would have asked something about how we didn’t have proper units for spice zest, and maybe come up with something else as well.

The problem is that far too often, when we write an example like this, we have exactly that problem. People ask questions around the irrelevant details suggested by variable names. The metasyntactic variables are one solution to this. In the functional programming world, another common solution is to use single-character variable names, because any meaningful name is going to make suggestions that are not generic enough. For instance, this is a common looking signature in Haskell:

liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

The function gets a real name, liftA2. The typeclass Applicative gets a name. But the variables f, a, b, and c do not. John Degoes’ Descriptive Variable Names: A Code Smell makes this point in detail.

I am not trying to push people to use foo here, only to make it clear why programmers often use it.

I have a whole list of nonsense words that I use in examples where I want to avoid any semantic implications due to the meanings of actual words:

foo, bar, baz, mumble, frotz, gronk, snork, snerfle, plurmb, argle, bargle, flibbity, flabbity, floop

-e

3 Likes

I want to take you seriously, not the example I gave.

I would prefer we change the metaphor to a new one, than let Metastatic variables to alter the metaphor used, and rather than foo Bar Baz I would use generic terms like child/parent/grandparent, set/subset, Table/Row/Field/cell that represent the data and give them say nouns as values.

This reminds me when I occasionally found in code a procedure called “I-dont-know-what-to-call-this-procedure” deep inside a complex algorithm. Sometimes it is almost inevitable, but trying to find better metaphors is the best approach in my view.

I also think that we in this thread have the experience abstracting to use metastatic variables, I think small short simple code, like @EricShulman’s which also well documented/described, see his answers throughout talk.tiddlywiki can sometime work with metastatic variables, but eric is logical and precise.

But, for a broader audience, real world metaphors are much more effective, designed correctly its easy to change an example, from one metaphor to another.

  • One problem with metastatic variables is they get defined by how they are used in your pseudocode, and may in fact be redefined in the same code, but the name does not carry any indication of its meaning or its place is, except by reference back to its use. Why would I use foo when something like “parent” is meaning full.
  • Its a not what you @Scott_Sauyet, @Springer or @EricShulman may do with metastatic variables (because you have the logic skills) its what the others will do with them or how they read them.
    • The use of metastatic variables is as I argue often used because the author cant find a good metaphor.
    • Especially when helping someone with a real world problem they have already presented the domain in which they are operating, there is no need for a metaphor. eg a Genealogical solution will use child/parent/grandparent so why introduce foo bar baz?

Sorry, that came out wrong. I meant that if you gave a response to my post that seemed as if you were taking my silly objections seriously. The whole point is that such objections get in the way of discussing the underlying meaning. They can often derail the discussion. (Notice that we haven’t actually talked about the “find the largest number” algorithm.)

Yes, my point was quite serious; my presentation was probably too frivolous.

And my objection is that any metaphor is likely to steer people wrong in technical discussions.

Looking at that first one, we can have reasonable discussions, using Family analogies for hierarchical data. Children usually works well, as it describes situations where an item can have zero, one, or many children. So can a person; the analogy is clear. But parent/grandparent are more problematic. “Wait, what do you mean this node has only one parent? All people have two. And no grandparents at all? That’s just crazy talk!”

We do often have to use analogies, especially in the names of our types of objects. We have trees, stacks, graphs, etc. Even “string” has nothing directly to do with twine/cord. They are definitely taken by analogy with their physical counterparts, but we define them by their data organization and the operations on them. But when we stretch these analogies too far, they become simple distractions.

To me, if I can’t name my functions appropriately, then my mental breakdown of the problem is still probably lacking. In such cases, where I’m talking about an action, I very intentionally use foo as the name, as a reminder to myself that I still need a real name. But that’s a very different use than I mentioned above.

Note that @Springer was arguing against them; she just happened to enjoy my particular usage here.

I’d say it’s because any single metaphor will likely distract from the main point and often let people think that the material is much more specialized than it really is.

Absolutely. These are used to discuss generic tools. Specific problems should use the appropriate language. But if in developing a specific problem, you use generic tools, there’s a call to make. If discussing that tool only in the context of your problem, by all means used the language from the problem domain. But if trying to explain the generic tool for itself, do not use the problem domain language, as it will often lead people to misunderstand the application.

1 Like

@TW_Tones:

Not wanting to be pedantic, but…

metaSYNTACTIC refers to nonsense words used as placeholders in computer programming.

metaSTATIC refers to a cancerous tumor that has spread to other parts of the body.

-e

Right. I wrote quotes from Crusoe about Crusoe to deal with the referentiality problem. e.g…

Crusoe wrote about Crusoe, whilst thinking Crusoe’s thoughts about thinking about Crusoe whilst writing about Crusoe being Crusoe. Being Crusoe … etc.

In the world of meta-syntactic variables Baz (='az) may be winning.

Isn’t he an Aussie?

Or was I thinking of “Bruce”?

Right.

(I am a social scientist, not a Gizmo Queen.)

It IS interesting, the OP, for showing, in practice The Holy Trio of FBB (Foo Bar Baz) has taken on canonical vestments. I.e. FBB sometimes muddies the waters?

@TW_Tones, to me, raises a broad issue in the OP.

But is it about TW or an even broader thing?

Just asking, TT.

Nice, I’ve never seen that before, but it makes sense.

1 Like

Agreed. Probably should go in the cafe. I’m willing to let it sit for a while.

I wonder why?
I wonder why I wonder?
I wonder why I wonder why I wonder?
I wonder why I wonder why I wonder why I wonder?
I…

<off-stage-voice>
Your dinner’s going cold!
</off-stage-voice>

1 Like

I wonder wonder, who, who wrote the book of love?

1 Like

My quick and non-programmer and non-educator take is that you should use the ‘Alice and Bob’ style in high-level examples most of the time, and generally be more specific in code.

For the high-l;evel examples, it’s important to give them a human face to create a sense of empathy with the user (in business, this is called “customer centricity”).

When it comes to code, say the foobar placeholders might be too generic. If someone is asking for help, you might be giving them overly general advice instead of helping with their specific issue.

Consider a different way to give a holistic answer: perhaps using a specific example (e.g. “PasswordChecker”), but then writing around it and explaining the more generic concept. It’s just giving generic advice, which is fine for a maths or computer science textbook, but not for real-world problems outside of the education realm.

1 Like

I should clarify that I’m not entirely averse to using foo, bar, and baz in appropriate circumstances. Among my many teaching roles over the years, one role that I enjoyed tremendously was teaching logic — and of course in logic the use of dummy predicates and dummy propositional variables is ubiquitous. Logicians, like programmers, deal regularly in semantically meaningless placeholders. These can be helpful in isolating abstract formal patterns without distraction.

The inference pattern we logicians call modus tollens, for example, can be described as moving from premises P implies Q and Q is false to the conclusion P is false.

The critical question, in considering whether to use such placeholders, is whether all participants in a particular conversation are already practically fluent with the logical structures at issue. The question is situation-specific: the effect of speaking in P⊃Q syllogism-talk (or in foo-bar-mumble-frotz-ese) is alienating if and when some would-be participants in the conversation don’t yet have confident feel for how the pattern under discussion works in actual reasoning.

We become fluent and confident with the structures of logic, or of programming, only through applications that connect with what we already know. For that reason, a single clear example of modus tollens, for the learner, is worth countless abstract representations. When someone doesn’t yet have the pattern clearly in mind, explaining it in abstract propositional terms (with Ps and Qs) is unhelpful.

Novice students can much more quickly orient to the pattern when they hear that modus tollens is what gets you from

If the battery is dead, the dome light doesn't come on — together with
Ah, the dome light *does* come on — to
So, the battery is NOT dead.

They need to get the hang of how that’s the same (useful) pattern as

If this instruction manual is Japanese, I can find some simple cursive-looking kana here
I can not find simple cursive-looking kana here
So, this instruction manual is not Japanese.

Until such inference patterns feel like shorthand that can be cashed out in helpful ways, describing an argument with propositional variables is like using a foreign language.

I am occasionally dismayed, in a forum like this, by a jargony post that comes across as announcing, “Hey, everyone, I found a way to convert foo 2 bar baz to bar baz foo foo!” or asking, “Hey, could someone just help me get from bar baz-baz-baz foo-foo to baz-baz foo?” (And of course it hardly helps if the bits are real words, but in nonsense roles like “grizzle bloke weasel stuff”.) The real effect is that some potentially interested users are likely to tune out. (Sometimes I wonder if that exclusionary effect ever serves as a feature — not a bug — of foo-bar-baz-ese for coder insiders.)

Some of the documentation at TiddlyWiki is a bit like this; other parts are — thankfully! — more accessible. In the absence of an intuitive practical application, learners may have to furrow their brows quite a bit to unpack why or whether this might be worth learning. Wading through a forum thread here whose title looks potentially helpful :thinking:, they may find a chunk of their time has been wasted in deciphering whether the conversation is even worth following, or contributing to.

Of course, no particular practical application or example is equally intuitive to everyone, and crafting a good accessible example can be time-consuming! There’s even a risk of being unwittingly exclusive, along different lines, if I set up an example that assume readers share certain parochial cultural or linguistic associations.

At any rate, I want to acknowledge, for @Scott_Sauyet and other occasional and careful users of nonsense placeholders, that foo and baz and their silly friends are not automatically irksome in my view. They can be a great addition to the party forum, provided they’re properly introduced and chaperoned.

3 Likes

Only my first reply is wandering off topic.

The English have a historical relationship to Australia, without going into the details, Baz, Bazza and Bruce are Sterio types used in humor that have aged poorly. These stereo types are not so common any more, they are Anachronistic and are usually maintained by people who don’t know how Australia has changed. In fact most Australians do not, and in many cases never did, look or behave like the character’s portrayed in humor especially the English think we are.

  • Australia Transitioned from a backwater in the mid 1900’s to an informed, eclectic society giving other countries a “run for their money”.
  • People like Barry Macenzie, Paul Hogan, Ralf Harris (now disgraced) and “Edna Everage” ( Barry Humphries ) played on such sterio types, in England, for Decades.
  • We need a new generation of comedians and satirists before we can be more effectively laughed about overseas.
    • We already do it well at home :nerd_face:

Yes, it is a greater thing, perhaps in coding standards and practice in any language, and even in pseudo code, but arguably this goes to “the way we think” and how “we respond to the world”, especially when we are trying to solve real world needs.

  • This even triggers my my Interest in Lay Philosophy.
  • Yes, poorly chosen metaphors are as unhelpful, or worse than, the also unhelpful “Meta Syntactics”.
  • One issue here is that people who can be good at coding are not always as creative with examples or communication methods.
  • I am not concerned with an individuals use of such variables for themself, if it works. I am concerned when it is used in communications. @EricShulman likes them as stated above, but his are always well explained, so he “gets away with it” :smiley:
  • It may be as simple as developing and publishing a set of useful metaphors along with the types of algorithms are needed within each. Like “Alice and Bob” have achieved. These are both metasyntactic and real world.
    • Even better if we have standard data sets to accompany such metaphors and examples.

@Springer addresses my concerns very well in the above reply :clap:

1 Like

In my mind they are characters “strung together”. But I no longer think of this, as “string” becomes a thing in its own right.

I think this can come about from the use of the genealogical metaphor where perhaps the tree metaphor would be better, But it is used so commonly including for backup generations (a timeline) etc… that it has taken on many roles. They tend to be contextually valid but writers should be aware and indicate the scope/context of their metaphor.

  • I am confident I am guilty of making assumptions with these metaphors. Hopefully not too often.
1 Like

Absolutely. And they will probably need examples to understand the general feel of modus ponens too. But I would expect pretty soon, P and Q become second-nature. By the time they reach De Morgan’s laws, they probably need fewer examples. To me that’s a matter of learning notation and conventions. (And of course the contemplation of an immortal Socrates!)

But examples are different from definitions. And if I’m going to define, say, a JS function that is fairly abstract, then I will use single-letter variables for most of my work. Here’s a typical example:

// maxBy :: (a -> a -> Bool) -> a -> [a] -> a
const maxBy = f => m => xs =>
    xs.reduce((c, x) => f(c)(x) ? c : x, m)

Note that all the variables outside the function name itself are single-letters, except xs, which is by convention how a list of items is written.

I might then give some examples—the maximum of a list of numbers, the string with the longest length, the rectangle with the largest area, and so forth—but my definition is too abstract to try to use variable names like nbr, str, or rect. The function covers them all, and choosing one of them may well cause the reader to miss the generality.

I use metasyntactic variables in a very similar manner.

1 Like

You would be my kind of teacher.

1 Like

Right!

And that was my point.

The “foo-bar-baz” trio (FBB) has become as much as a cliché as disparaging UK comments on Aussies have become.

My point? People explaining code are still people.
Often it is RITUAL
It is rarely a value free act.
It is normally embedded in a social context.

IMO an Ethnomethdology would best provide a way to answer your socio-cultural OP.

TT

1 Like

The thing is if your writting is to be read by a broad audience you need to back it up with supporting details, as @EricShulman does, and this allows him to utilise metastatic variables and still be an effective communicator.

I personally think in this forum with a broad audience we would be better finding suitable metaphors and use real world language rather then metastatic variables that contain in them little or no information.

  • Sure use metastatic variables if you want, but please keep the audience in mind.
  • It is my view this tends to mean don’t use them.
1 Like