Live data from Hacker News

0xCAFEBABE & 0xFEEDFACE (2003)

radio-weblogs.com

21–30 of 126 posts

Re: 0xCAFEBABE & 0xFEEDFACE (2003)

#24

Rust will yell at you if you use specific magic numbers like these edit: yes, 0xCAFEBABE is a warning but 0xFEEDFACE is not: 3405691582 https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e...

But why?

https://www.oxfordlearnersdictionaries.com/definition/englis...

> but sometimes considered offensive if used by a man to a woman he does not know

There are billions of other magic numbers to choose from anyway.

Re: 0xCAFEBABE & 0xFEEDFACE (2003)

#26
post #9

Earlier quoted context omitted.

That's a Code of Conduct violation. It's not the 90s anymore, there's no quarter for this type of thing in modern development teams. Rust's style checker even flags up the use problematic magic numbers.

This is only for rustc, not for arbitrary rust programs.

Wouldn't rustc flagging "problematic" numbers prevent arbitrary rust programs from having them in the source?

Re: 0xCAFEBABE & 0xFEEDFACE (2003)

#27
Semi-related story with some insider baseball:

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.

Re: 0xCAFEBABE & 0xFEEDFACE (2003)

#29

Rust will yell at you if you use specific magic numbers like these edit: yes, 0xCAFEBABE is a warning but 0xFEEDFACE is not: 3405691582 https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e...

Kind of low-key hilarious that someone thought this was a serious enough issue to actually submit that code. I wonder if there is a written spec that helps to judge which integers should be considered "problematic" and which ones aren't.

Not just that, but they also wrote the numbers in decimal - they didn't even want them in the code as an example of what not to do.

Maybe someone was having too much fun and got carried away, but what an odd sense of humor.

Re: 0xCAFEBABE & 0xFEEDFACE (2003)

#30

Rust will yell at you if you use specific magic numbers like these edit: yes, 0xCAFEBABE is a warning but 0xFEEDFACE is not: 3405691582 https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e...

No wonder the compile times are so slow. Rustc comes with built-in content moderation!

Anyway I think they forgot a few, like 173406926 (// Intentionally written in decimal rather than hex). Seems like they just checked https://en.wikipedia.org/wiki/Hexspeak. Kind of a weak effort, overall.

Post reply on HN