Foo 是什么意思
参考:http://www.cnblogs.com/felicity/archive/2010/11/30/1892100.html
不管是 Java、C++ 还是 PHP,每次都能看到 foo = bar 的例子,这两个单词很让人费解,foo 查不到字典,bar 的解释又让人跟编程联系不上,更弄不清楚这个神秘的 foo 是个什么关系。
语意不清,学起来心里老是有疙疙瘩瘩的感觉,于是查吧,终于揭开了这两个东西的不正常关系,讲给各个处在闹心中的初学者们听吧。
参考了众多的网络资料,最后,明确地告诉大家,foo 和 bar 就是外国人的张三、李四、王二麻子,只是一种随便的命名方式,跟 C 语言里面的 i、j、k 同出一辙。
也就是说 foo = bar 跟"变量张三 = 李四的侄子"是一个意图,所以童鞋们就不要再找 foo 到底是个啥了。
问 foo 是啥就跟问张三是谁一样,我想外国人一定也很想知道张三到底是谁,这个人怎么这么有名,总能看到这个名字,但是历史上记载却又找不到他。
为了这个可恶的 foo,居然还动用 RFC 给 foo 下了一个明确的词源追踪,无聊的童鞋可以看 RFC 3092 解解闷。
民间说法
下面是网上搜刮来的各种解释:
- Foo:本意指程序员用来代表数据、功能或命令的变量。O’Reilly 媒体认为 FOO 是 Friends of O’Reilly 的缩写,并把他们在 2003 年举办的年会命名为 “2003 FOO”,现在则更多地指声势浩大的某行业大会
- foo = fuck oriented object
- foo 是"你要让它是什么就是什么",FOO 可以具有用户赋予的任何意义
- foo 是潦草的意思,表示很随便的定义
- foo 没有意义
- foo 的意思是 Factory Of Objects
- foo:一塌糊涂;bar:一团糟
- foo
不同的字典对其解释相去甚远,一说来自中国"福"字的发音,又有解释为二战时期的一种武器。然而若把众多的解释放在编程领域,关于 foobar 的说法是最贴切的解释:foobar 又为 foo-bar,其中 bar 是 beyond all recognition 的缩写,通俗点就是无法识别、一塌糊涂的意思,而 foo 是 fu 的变体,fu 是英语习语 fuck-up 的缩写,同样是一团糟的意思。于是,若你有些编程经验,应该已经明白了为何如今许多编程实例所涉及的事物均被冠名为 foo。
RFC 3092 中文译注
1. 介绍
至今约有 212 个 RFC,或者约 7% 的 RFC,从 RFC 269 开始,包括了术语 “foo”、“bar” 或 “foobar” 作为伪变量而没有任何适当的解释或定义。这可能被认为是微不足道的,但一些新来者,特别是那些非英语国家的人,在理解这些术语时会遇到困难,本文纠正这一问题。
2. 定义和语源
bar /bar/ n. [JARGON]
- 第二个伪变量,在 foo 之后而在 baz 之前。例如:“Suppose we have two functions: FOO and BAR. FOO calls BAR….”
- 经常加在 foo 后面构成 foobar。
foo /foo/
- interj. 令人反感的术语。
- 用于任何东西的一般名称,特别是程序和文件(特别是草稿文件)。
- 用于语法例释的标准伪变量表中的第一个(bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud)。[JARGON]
当连接 “bar” 时通常可以追溯到二战时军中的俚语 FUBAR(Fucked Up Beyond All Repair),最后演变成了 foobar。早期版本的 Jargon File [JARGON] 称这一变化是战后的修正,但现在看来更像是 FUBAR 本身是 “foo” 的衍生词,可能是受到了德语 “furchtbar”(可怕的)的影响——也许最初形式是 “foobar”。
似乎 “foo” 这个词在战前的漫画和卡通中可以找到历史。在 1938 年华纳兄弟卡通公司 Robert Clampett 指导的 “The Daffy Doc” 中,Daffy Duck 的早期版本有一句口号 “SILENCE IS FOO!"。“FOO” 和 “BAR” 也在 Walt Kelly 的连环漫画 “Pogo” 中出现。最早有文献记载的使用是在 Bill Holman 的一个消防队员的超现实主义连环漫画 “Smokey Stover” 中。在 1930 到 1952 年间该连环漫画出现在许多美国漫画中,包括 “Everybody’s”。它经常在汽车的车牌中包含单词 “FOO”,在背景画面中无意义的话中,如 “He who foos last foos best” 或 “Many smoke but foo men chew”,Smokey 说 “Where there’s foo, there’s fire”。Bill Holman,该漫画的作者,在其中充满了奇妙的笑话和个人发明,包括其它无意义的短语如 “Notary Sojac” 和 “1506 nix nix”。依照华纳兄弟卡通公司 [WBCC] 的说法,Holman 是在一个中国小雕像的底部发现 “foo” 这个词的。这是个似是而非的说法;中国的小雕像经常有避邪用的题字,这可能是中文 “fu”(有时候音译为 “foo”),当发音正确时意为"幸福”(立在许多中餐馆侧面的狮子-狗型守护神正确的称呼是 “fu dogs”)[PERS]。说英语的人认为 Holman 的 “foo” 这个无意义的词毫无疑问地受到 Yiddish 语的 “feh” 和英语的 “fooey” 以及 “fool” 的影响。[JARGON, FOLDOC]
Holman 的漫画描写了一台两轮消防车名叫 Foomobile。该系列漫画在 1930 年代后流行极了,传说 Indiana 的一个制造商甚至造出了一台可操作的 Foomobile。按照美国漫画百科全书 [EAC] 的说法,“Foo” 热横扫美国,在流行歌曲和超过 500 个 “Foo 俱乐部” 中可以找到证据。作为流行的遗迹,“foo” 嵌入了流行文化(包括华纳兄弟卡通公司 1938-39 年的几次亮相)但它的起源被迅速遗忘了。[JARGON]
二战后该术语在美国军队仍存留下来。在 1944-45 年,术语 “foo fighters” [FF] 被雷达操作员用来描述一种神秘的或伪造的轨迹,那后来被称为 UFO(在 1995 年通过一个叫 Foo Fighters 的乐队词老的术语又重新露面)。据信它和漫画 Smokey Stover 有关 [PERS]。
战争中美国和英国军队经常交换俚语。Period sources 报告说二战中 “FOO” 变成了半传奇式的主题,英国军队的涂鸦或多或少等于美国的 Kilroy [WORDS]。英国军队走到哪里,都会涂上 “FOO was here” 或者类似的话。几本俚语字典断言 FOO 来自前线巡查官,但这(像同时代的 “FUBAR”)也许是 backronym [JARGON]。40 年后,Paul Dickson 的著作 “Words” [WORDS] 追踪 “Foo” 到了一个不明的英国海军杂志,引用如下:
“Mr. Foo is a mysterious Second World War product, gifted with bitter omniscience and sarcasm.”
更早版本的 Jargon File 暗示其用法的可能来自 “FOO, Lampoons and Parody”,1958 年发行的一本漫画的标题,Charles 和 Robert Crumb 合作的一个项目。
尽管 Robert Crumb(在他后来十几年)后来成了最重要最有影响力的地下漫画作家,这次成功相当艰难;实际上,因为厌恶,兄弟俩后来烧掉了大部分的拷贝,标题 FOO 用大号字印在封面上。然而,非常少的拷贝确实流传了下来,Crumb “全集” 的学生确定它参考的是较早的 Smokey Stover 漫画。Crumb 的作品可能也受到 1951-52 年出版的短命加拿大滑稽杂志 “Foo” 的影响 [JARGON]。
一个 old-time 成员报告说,在 1959 年 TMRC(MIT 的技术模型铁路俱乐部)编译的 “TMRC 语言字典” 中有 Foo 的词条。当前在线版本中的 “Foo” 是唯一标记为红色的词,有如下内容 [TMRC]:
Foo: The sacred syllable (FOO MANI PADME HUM); to be spoken only when under obligation to commune with the Deity. Our first obligation is to keep the Foo Counters turning.
这个定义用了 Bill Holman 的无意义的词,流行之后 20 年且确实存在于流行文化和俚语中,使一个 “ha ha only serious” 像西藏佛教一样深奥。今天的人会发现很难抵挡这样精心制作的笑话,而不像 1959 年代的人那样不易受感染。[JARGON]
3. 其他义项
- [EF] 王子 Foo 是 Pheebor 最后的统治者,和 Phee Helm 的所有者,在 reign of Entharion 之前约 400 年。当 Foo 被来自 Borphee 的叫作 “eastern fop” 的什么人砍头时,Pheebor 的显赫时代结束了,而 Borphee 越升到它现在的位置。
- [OED] 一个 13-16 世纪用法,指恶魔或任何敌人。最早的引用是在 1366 年,Chaucer A B C (84):“Lat not our alder foo [devil] make his bobance [boast]"。Chaucer 的 “Foo” 可能是现代英语的 “foe”。
- 稀有种类的狗——波美拉尼亚丝毛狗,被认为已灭绝。
RFC 3092 原文(英文)
foo /foo/
- /interj./ Term of disgust.
- Used very generally as a sample name for absolutely anything, esp. programs and files (esp. scratch files).
- First on the standard list of metasyntactic variables used in syntax examples. See also bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud.
The etymology of hackish foo is obscure. When used in connection with bar it is generally traced to the WWII-era Army slang acronym FUBAR (“F-u-c-k-e-d Up Beyond All Repair”), later bowdlerized to foobar. (See also FUBAR.)
However, the use of the word foo itself has more complicated antecedents, including a long history in comic strips and cartoons. The old “Smokey Stover” comic strips by Bill Holman often included the word FOO, in particular on license plates of cars; allegedly, FOO and BAR also occurred in Walt Kelly’s “Pogo” strips. In the 1938 cartoon “The Daffy Doc”, a very early version of Daffy Duck holds up a sign saying “SILENCE IS FOO!” Oddly, this seems to refer to some approving or positive affirmative use of foo. It has been suggested that this might be related to the Chinese word fu (sometimes transliterated foo), which can mean “happiness” when spoken with the proper tone (the lion-dog guardians flanking the steps of many Chinese restaurants are properly called “fu dogs”).
Paul Dickson’s excellent book “Words” (Dell, 1982, ISBN 0-440-52260-7) traces “Foo” to an unspecified British naval magazine in 1946, quoting as follows: “Mr. Foo is a mysterious Second World War product, gifted with bitter omniscience and sarcasm.”
Other sources confirm that FOO was a semi-legendary subject of WWII British-army graffiti more-or-less equivalent to the American Kilroy. Where British troops went, the graffito “FOO was here” or something similar showed up. Several slang dictionaries aver that FOO probably came from Forward Observation Officer. In this connection, the later American military slang foo fighters is interesting; at least as far back as the 1950s, radar operators used it for the kind of mysterious or spurious trace that would later be called a UFO (the older term resurfaced in popular American usage in 1995 via the name of one of the better grunge-rock bands).
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.
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. Almost the entire staff of what later became the MIT AI Lab was involved with TMRC, and probably picked the word up there.
Very probably, hackish foo had no single origin and derives through all these channels from Yiddish feh and/or English fooey.
维护记录
| 时间 | 修改内容 | 原因 |
|---|---|---|
| 2026-07-16 | 整理全文结构,补充二级/三级标题、列表与引用块;合并原文中因排版产生的断行;补充 lastmod;标签由 reprint 改为 remix + AI-assisted 并新增 jargon |
原文格式混乱,段落断行零碎,缺少层级标题,不符合站内 Markdown 规范 |