TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Endiannes and Polymorphism in Rust

38 pointsby loigeover 3 years ago

7 comments

bruce343434over 3 years ago
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:&#x2F;&#x2F;gitlab.com&#x2F;xmdr&#x2F;ananke&#x2F;-&#x2F;blob&#x2F;master&#x2F;drafts&#x2F;example.md" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;xmdr&#x2F;ananke&#x2F;-&#x2F;blob&#x2F;master&#x2F;drafts&#x2F;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.
评论 #29416049 未加载
评论 #29414432 未加载
Taniwhaover 3 years ago
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&#x27;m currently working with number their GPIOs this way too)
magicalhippoover 3 years ago
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?
评论 #29416126 未加载
评论 #29415165 未加载
kstenerudover 3 years ago
The natural endianness is &quot;little endian&quot;, 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:&#x2F;&#x2F;www.technicalsourcery.net&#x2F;posts&#x2F;on-endianness&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.technicalsourcery.net&#x2F;posts&#x2F;on-endianness&#x2F;</a>
评论 #29416734 未加载
MrBuddyCasinoover 3 years ago
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?
评论 #29416089 未加载
评论 #29416957 未加载
zwirblover 3 years ago
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
评论 #29414648 未加载
评论 #29414742 未加载
nick_over 3 years ago
If this was HN front page bingo, we&#x27;d have a winner.