0xCAFEBABE & 0xFEEDFACE
The origins of magic numbers 0xCAFEBABE and 0xFEEDFACE in Mach-O and Java files were discussed, revealing their selection process and the amusing anecdotes behind them, highlighting computer history's complexities.
Read original articleThe discussion revolves around the origins of the magic numbers 0xCAFEBABE and 0xFEEDFACE, which are used in Mach-O file formats and Java class files. The conversation began among former NeXT employees, with one participant questioning why Java adopted 0xCAFEBABE as its magic number. Mike DeMoney, who worked at NeXT and later at Sun, clarified that he did not choose the magic numbers for Java, as they were established before his arrival. He speculated that the similarity might stem from the limited number of appealing hex words available. James Gosling, a key figure in Java's development, later explained that he chose 0xCAFEBABE while looking for hex words to use as magic numbers for file formats, inspired by a local café's name. He initially used CAFEDEAD for another format, but it was eventually discarded. The conversation highlights the amusing and often convoluted nature of computer history, where stories can evolve and be misattributed over time.
- The magic numbers 0xCAFEBABE and 0xFEEDFACE are used in Mach-O files and Java class files.
- Mike DeMoney clarified he did not choose the magic numbers for Java; they were selected before he joined the team.
- James Gosling revealed that 0xCAFEBABE was chosen based on a café's name and the search for appealing hex words.
- The discussion illustrates how computer history can be shaped by anecdotes and misattributions.
- The limited number of interesting hex words may explain the coincidence of similar magic numbers across different platforms.
Related
Round Rects Are Everywhere
In 1981, Bill Atkinson developed oval routines for Macintosh. Steve Jobs challenged him to create rounded rectangles, leading to the "RoundRects" feature. This anecdote showcases innovation and collaboration in early Macintosh development.
Migrating from Java 8 to Java 17 II: Notable API Changes Since Java 8
The article details API changes in Java versions 9 to 17, emphasizing improvements for Java 8 migrations. Changes include null handling, performance enhancements, string improvements, switch expressions, record classes, and utility additions for developer productivity and code readability.
The good, the bad, and the weird (2018)
Trail of Bits delves into "weird machines" in software exploitation, complex code snippets evading security measures. Techniques like Hoare triples and dynamic_casts aid in identifying and preventing exploitation, crucial in evolving security landscapes.
The history of Alt+number sequences
The history of Alt+number sequences on IBM PCs and Windows systems is explored. Users could enter characters by pressing Alt and typing decimal values on the numeric keypad, leading to discrepancies in character display based on the input control used.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
- Users suggest alternative magic numbers, such as 0xDECAFBAD and 0x4D494B45, sharing personal anecdotes about their use.
- Several comments mention the concept of hexspeak and its amusing implications in coding.
- There is a discussion about programming languages like Rust that flag the use of specific magic numbers.
- Some users share their experiences with creating or using random hex values for fun or practical purposes.
- Overall, the comments highlight the creativity and humor found in the use of magic numbers in programming.
Even more interesting is the Wikipedia page https://en.wikipedia.org/wiki/Hexspeak catalogs a delightfully long list of hexspeak words and what they're used for.
There are quite a few memorable words you can spell using 32 or 64 bits—like BA5EBA11. This is the story of me -not- choosing one of those.
These bit-pattern words are handy because they’re easy to recognize, especially in a random memory dump.
On my first “real” assignment, I was writing real-time embedded C code for a 16-bit processor that communicated with a host microprocessor on a server. We needed to run periodic assurance tests across a bus to ensure reliable communication with the host since we weren't constantly using the bus.*
We were given an unused register address on the host processor and told to write whatever we wanted to it. The idea was to periodically write a value, read it back, and if we encountered any write errors, incorrect reads, or failures, we’d declare a comm error and degrade the system in a controlled manner.
Instead of using zeros or something like 0xDEADBEEF, I decided to write 0x4D494B45 - "MIKE" in ASCII. It was unique, unlikely to be tampered with, it worked, and no one argued with me. The code shipped, the product shipped, and all was well. We even detected legitimate hardware errors, which I thought was pretty cool.
Fast forward two generations of systems, and long after I’d moved on from that team, the code had been ported around but that assurance test remained unchanged. Everything was fine until they brought up a new generation of systems, flipped on the firmware for that device, and 10 seconds later, my assurance test clobbered an important register. The entire system promptly checkstopped and crashed. It took the team days to figure out what was wrong, and I had to explain myself when they found "MIKE" staring back at them from the memory dump.
That was a fun project. ;-)
* Note: It would've been bad if our device went out to lunch because we were responsible for energy management of the server. If the power budget was exceeded and we couldn't downclock and downvolt the processor, something might have crashed or been damaged.
edit: yes, 0xCAFEBABE is a warning but 0xFEEDFACE is not:
3405691582
https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e...
Related
Round Rects Are Everywhere
In 1981, Bill Atkinson developed oval routines for Macintosh. Steve Jobs challenged him to create rounded rectangles, leading to the "RoundRects" feature. This anecdote showcases innovation and collaboration in early Macintosh development.
Migrating from Java 8 to Java 17 II: Notable API Changes Since Java 8
The article details API changes in Java versions 9 to 17, emphasizing improvements for Java 8 migrations. Changes include null handling, performance enhancements, string improvements, switch expressions, record classes, and utility additions for developer productivity and code readability.
The good, the bad, and the weird (2018)
Trail of Bits delves into "weird machines" in software exploitation, complex code snippets evading security measures. Techniques like Hoare triples and dynamic_casts aid in identifying and preventing exploitation, crucial in evolving security landscapes.
The history of Alt+number sequences
The history of Alt+number sequences on IBM PCs and Windows systems is explored. Users could enter characters by pressing Alt and typing decimal values on the numeric keypad, leading to discrepancies in character display based on the input control used.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.