I’m writing my own programming language that deals with this in a different way. You have your variables, and you have qualifiers like const or mutable. There’s also storage order qualifiers. When you say “bigend i32” that means a 32 bit integer which will be laid out as big endian in memory. But you can still use it normally, to the programmer it has no weird inverted value.<p><a href="https://gitlab.com/xmdr/ananke/-/blob/master/drafts/example.md" rel="nofollow">https://gitlab.com/xmdr/ananke/-/blob/master/drafts/example....</a><p>So far, progress has been a bit slow. I still don’t have a working interpreter, not to mention compiler, because I find myself tweaking the syntax a lot. Perhaps later in december it will have finalized enough for me to dare write it out.
Endianness within bytes (or words) is actually a thing<p>- IBM long numbered bits from the most significant starting with 0 (think of 360s and the like, not PCs)<p>- there are modern chips with registers numbered the same way (a current family of multi-core ARM chips I'm currently working with number their GPIOs this way too)
Given that most CPUs are or can run in little-endian mode these days, why are so many <i>new</i> protocols and file formats using big-endian for storing numbers, like record lengths etc?
The natural endianness is "little endian", as it was originally devised in India. We just do it backwards (big endian) in left-to-right writing systems due to inertia (though originally for backwards compatibility with existing mathematical texts in the 10th century).<p>Little endian has too many advantages to be ignored, which is why all popular architectures and also newer protocols are now little endian.<p>I did a write-up about it here: <a href="https://www.technicalsourcery.net/posts/on-endianness/" rel="nofollow">https://www.technicalsourcery.net/posts/on-endianness/</a>
This is a good explanation, but I still find this a difficult concept to wrap my head around. I think the main source of confusion is that endianness (usually) concerns bytes, not words. Why is this the case? ALUs work on words, not bytes, right?
If I ever got a tattoo, I would get an explanation of endianness on my left arm because I always mix them up<p>Sure the concept is easy, but have you ever met someone who mixes left and right up? It can be quite catastrophic in traffic