Jag ser ofta i exempelkod att man använder "foo" som namn på variabler eller objekt, och tänkte att det måste ha ett ursprung någonstans. Nyfiken som jag är tänkte jag gå till botten av detta och fråga er var uttycket kommer ifrån.
RED: Detta hör sannolikt mer hemma i "Programmering Övrigt", så någon kan väl flytta inlägget dit om det stör.
Ok, då har jag förklaringen av ordet "foo". Men finns det någon speciell anledning till att det används av programmerare, eller var det bara någon som började använda det, och sedan följde andra efter?
Earlier versions of this entry suggested the possibility that hacker usage actually sprang from "FOO, Lampoons and Parody", the title of a comic book first issued in September 1958, a joint project of Charles and Robert Crumb. Though Robert Crumb (then in his mid-teens) later became one of the most important and influential artists in underground comics, this venture was hardly a success; indeed, the brothers later burned most of the existing copies in disgust. The title FOO was featured in large letters on the front cover. However, very few copies of this comic actually circulated, and students of Crumb's `oeuvre' have established that this title was a reference to the earlier Smokey Stover comics. The Crumbs may also have been influenced by a short-lived Canadian parody magazine named `Foo' published in 1951-52.
An old-time member reports that in the 1959 "Dictionary of the TMRC Language", compiled at TMRC, there was an entry that went something like this:
FOO: The first syllable of the sacred chant phrase "FOO MANE PADME HUM." Our first obligation is to keep the foo counters turning.
(For more about the legendary foo counters, see TMRC.) This definition used Bill Holman's nonsense word, only then two decades old and demonstrably still live in popular culture and slang, to a ha ha only serious analogy with esoteric Tibetan Buddhism. Today's hackers would find it difficult to resist elaborating a joke like that, and it is not likely 1959's were any less susceptible. Almost the entire staff of what later became the MIT AI Lab was involved with TMRC, and the word spread from there.
Anledningen till att foo och bar är så användbara för programmerare är ju att man ofta behöver ett par godtyckliga namn och ett godtyckligt tal för att beskriva något, typ "Antag att du har en klass foo som implementerar interfacet bar. Låt säga att foo:s konstruktor tar en int som argument och du skickar in 4711... osv".
Talet 4711 är likt foo och bar en användbar och uppskattad entitet som används när man behöver "ett godtyckligt stort tal" :).
Om sen foo och bar = foobar = fubar är sant, dvs att det ursprungligen kommer från "fucked up beyond all repair", det står nog höljt i en mystisk dimma.