The heart is a bloom , shoots up through the stony ground.


CAFEBABE和Grateful Dead



魔数(Magic Number)又称魔法值,是指在代码中出现但没有解释的数字常量或字符串,。如果在某个程序中你使用了魔数,那么在几个月或几年后你将很可能不知道它的含义是什么。

关于Java语言的魔数cafe babe,Java之父James Gosling在博客里是这样写的:

We used to go to lunch at a place called St Michael’s Alley. According to local legend, in the deep dark past, the Grateful Dead used to perform there before they made it big. It was a pretty funky place that was definitely a Grateful Dead Kinda Place. When Jerry died, they even put up a little Buddhist-esque shrine. When we used to go there, we referred to the place as Cafe Dead.

我们过去经常去一个叫St Michael’s Alley的地方吃饭(硅谷附近的一个餐馆),根据这里的传闻,在黑暗的过去(应该指的是那个疯狂的年代),Grateful Dead在成名之前曾在这里演出。这绝对是一个时髦到让人”感恩至死”的地方。在Jerry(主唱Jerome John Garcia)死后,他们甚至放置了一个小型的佛教祭坛。我们以前去那里的时候,会把这个地方称为Cafe Dead(大概是调侃祭坛)。

Somewhere along the line it was noticed that this was a HEX number. I was re-vamping some file format code and needed a couple of magic numbers: one for the persistent object file, and one for classes. I used CAFEDEAD for the object file format, and in grepping for 4 character hex words that fit after “CAFE” (it seemed to be a good theme) I hit on BABE and decided to use it. At that time, it didn’t seem terribly important or destined to go anywhere but the trash-can of history. So CAFEBABE became the class file format, and CAFEDEAD was the persistent object format. But the persistent object facility went away, and along with it went the use of CAFEDEAD - it was eventually replaced by RMI.

忽然我注意到这正式一串十六进制数字(16进制中,11-16分别是A-F,CAFE DEAD这几个字母分别符合)。我当时正在重新修改一些文件格式代码,需要几个魔数:一个用于持久对象文件,一个用于类。我决定用CAFEDEAD作为对象文件格式,并且再找4个字母拼接在CAFE后面,作为类文件的魔数。在那个时候,除了历史的垃圾桶外,这两个魔数似乎并不重要或注定要被遗忘。所以CAFEBABE成为了类文件的魔数,CAFEDEAD则是持久化对象的魔数。但是后来持久对象工具消失了,随之而来的就是, CAFEDEAD 最终被 RMI 取代。(难怪没有听说过)


关于St Michael’s Alley餐馆和Grateful Dead

在记载Palo Alto历史的网站上找到了,确有此事:

In 1960, 18-year-old Jerry Garcia arrived in Palo Alto.

… …

At the time, the daytime center of literary and intellectual activity for Palo Alto youth was actually in Menlo Park at Kepler’s Books on El Camino.

… …

At night, the action tended to shift over to St. Michael’s Alley, a funky Palo Alto coffee shop at 436 University which had launched Joan Baez a couple years earlier.

大概就是,1960年,18岁的Jerry就来到了Palo Alto,然后经常参加一些知识分子嬉皮士)聚会,St. Michael’s Alley就是集会点之一,并且Joan Baez也是在这里出道的。