Why 0xCAFEBABE?

36 points by connorboyle


juliethefoxcoon

This post is mostly just speculation. If you want the actual answer for why CAFEBABE was chosen, james gosling himself actually gave an answer

As far as I know, I'm the guilty party on this one. I was totally unaware of the NeXT connection. The small number of interesting HEX words is probably the source of the match. As for the derivation of the use of CAFEBABE in Java, it's somewhat circuitous:

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. 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.

mdaniel

Twenty-something years ago the Burroughs B6700 initialized its "uninitialized" memory of 48-bit words to 0xBADBADBADBAD

OT1H, very cool; OTOH, 48 bit words :-D I presume that's related to BCD being 6bit

lake

Subject: Re: Why CAFEBABE?

Date: Wed May 22 09:17:37 1996

Since the word babe is pretty synonmous with chick, I doubt you'll find any deep meaning here. When I hear "CafeBabe" I think of a typical Coffee Grrl: nose peirced, minimum one tatoo, hair dyed black, hate the world the government and parents, and is rather attractive in a necro sort of way.

stay awesome, 1996.

jcc333

Good ole' 0xBEEFBEEF would never steer you wrong

dimonomid

Pretty common technique to use such "cool" numbers for similar purposes.

My old Tneo RTOS project still uses 0xFEEDFACE to initialize tasks stack, useful to see unused stack space in debugger.

0xCAFEBABE is indeed very fitting for Java btw, I like that.

baetylboy

The magic for the Linux device tree blob file format is d00dfeed which I find pretty funny

danso

While we're sharing our favourite 32-bit values, I'm aware of a few indie/hobby projects using 0xACAB1312 as their magic number.