The variable names, 'foo' and 'bar', are evil

Scenario: Someone asks a vague question on Stackoverlow, and even though you could get away with trolling out a request for clarification, you know the answer, and it's an easy answer. So you take the bait, and roll out a perfectly clear example of a solution. Let's say the question is one that I've recently asked: how do you actually use the /: and :\ operators in Scala? (Turns out this is nearly impossible to Google, and the Scala docs are, well... they are Scala docs—skeletal, ghostly, intriguing and alluring, yet in the end, just a tantalizing taste of understanding.)

Duh, you say, obviously they're just folds and you use them like this:

        val foo = List(...)
        var bar = List(...)
        val foobar = (foo /: bar)((a, b) => a + b)
Wow, thanks, I learned nothing, except that the characters f, o, b, a, and r are valid characters in Scala variable names. Am I stupid? Kind of. That's why I asked the question.

Programming is semantic, in the sense of programming vs. computer science, which is something like 95+% of all the programming that is done. Your variables refer to things in the real world: final sale price, lat/lon of user's last tweet, average heart rate, etc. What's more, applicable scenarios are effortless to fabricate. Let's take one more stab at the question:

        val initial_savings = 10.0
        val incoming_checks = List(45.4, 90.9, 108.03, 60.9)
        val savings = (initial_savings /: incoming_checks) {
          (cumulative_savings, check) =>
            cumulative_savings + check
Sure, this is absolutely trivial, and a better solution to this task would be
        val savings = initial_savings + incoming_checks.sum
But it still conveys the idea of folding, along with folding syntax, much more clearly. Folding is kind of complex, particularly for imperativists, so an answer where folding is really the most elegant solution is probably going to be slightly more complex than necessary to answer the question. The way I see it, it's like wrapping recursion around something that does not (or cannot elegantly) support recursion itself. For example, here's one of my simpler applications:
      val lines = (List(List(node)) /: (0 until level)) {
        case (accumulator, level) =>
          // accumulator(level) should equal accumulator.last
          accumulator :+ accumulator(level).flatMap { node =>
            node match {
              case split_node: SplitNode => List(split_node.left, split_node.right)
              case spacer_node: SpacerNode => List(spacer_node.child)
              case _ => List()
Maybe the real-world example is even clearer. Either way, the actual example is helpful. The foo-bar soup is not.

So, dear O'Reilly writers and StackOverflow experts, please use examples for your examples. The syntactically correct gibberish may compile, but that's not the point. The point is for me, the learner, to recognize both where/why I ought to use a certain syntax and how to use it.

Finally, is it not a giveaway that "foo bar" is how you pronounce FUBR, i.e. "Fucked Up Beyond Recognition"?


More recently, The Guardian posted a translation of Lorem Ipsum, which I think is illustrative:

Rrow itself, let it be sorrow; let him love it; let him pursue it, ishing for its acquisitiendum. Because he will ab hold, unless but through concer, and also of those who resist. Now a pure snore disturbeded sum dust. He ejjnoyes, in order that somewon, also with a severe one, unless of life. May a cusstums offficer somewon nothing of a poison-filled. Until, from a twho, twho chaffinch may also pursue it, not even a lump. But as twho, as a tank; a proverb, yeast; or else they tinscribe nor. Yet yet dewlap bed. Twho may be, let him love fellows of a polecat. Now amour, the, twhose being, drunk, yet twhitch and, an enclosed valley's always a laugh. In acquisitiendum the Furies are Earth; in (he takes up) a lump vehicles bien.

This is cute, but hardly better than the original Lorem Ipsum for the intended purpose.