Hacker News new | ask | show | jobs
by gU9x3u8XmQNG 629 days ago
I 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.

3 comments

It'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.
I 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.
I 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.
I agree, to me it's always looked like baby speak.

Reading about "FUBAR" makes it even worse.