Complicated question....

Why is it in programming books they always have a function or variable called FOO?

fun oriented object

Are you sure?

Foo means different things in different places.
Here, foo means “Forum - OpenGL Only”

Simply for geek historical reasons.

I beleve ‘foo’ is short from ‘foobar’ which is really ‘FUBAR’ which means " ‘fouled’ up beyond all recognition."

A cousin of SNAFU “situation normal all ‘fouled’ up.”

I think the terms originated in the military but most would agree they are pertinent to coding.

Originally posted by Coconut:
Foo means different things in different places.
Here, foo means “Forum - OpenGL Only”

Very good.

The word has a long and interesting history
http://www.faqs.org/docs/jargon/F/foo.html

The most geeky description I have found is that a ‘foo’ was a spurious electronic signal and a foobar was the inverted/complement signal.