Endian Reservations
© 2006 James Dempsey
You might have some endian reservations
Over bit flipping’ head trippin’ complications
Getting it right, how every byte is interpreted
‘Cause if your processor changed
it might not keep things arranged like the last one did
Eight bits make up a byte, each bit is active or it slumbers
But eight is not enough to represent the larger numbers
So bytes are strung together now, in twos and fours and eights
Each byte contains a portion of the represented state
None of these bytes is insignificant, but some moreso than others
Each is more or less significant than its sisters and brothers
So do you store them least to most, or arrange them most to least?
It’s this ordering conundrum that’s the nature of the beast
You might have some endian reservations
Over network byte order situations
What can transpire pulling bits off the wire has you ill at ease
Your code could give up the ghost without those network to host-type utilities
My processor says pa-tah-toe and yours says puh-tay-tah
Two different patterns represent the same data
One puts significance first, the other saves it for later
The most annoying switcheroo since Anakin became Vader
You might have some endian reservations
Over file format specifications
What is the risk, dealing with files on disk is what you want to know
The file header should mention, or its simply convention how the bytes should go
Well do you have to break this code or has someone else cracked it?
You can use an API that’s already abstracted
Your development cycle won’t be greatly impacted
Then you can blog all about it like some guy on Dot Mac did.
You’ve dealt with all your endian reservations
The jaw droppin’ byte swappin’ permutations
Fixed every goof, made your code bulletproof and unassailable
And so for every byte that you had to reverse, and for any late night that made you mutter and curse
We’d like to thank you for making your app universally available.
Endian Reservations debuted at WWDC 2006, one year after the announcement of the move from to Intel processors from PowerPC.
Vocals: James Dempsey
Guitar: Gordie Freedman
Music and Lyrics: James Dempsey
Recorded and Produced by Russell Bond at The Annex Studios