Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know that's the standard but for all private projects I always write little endian so I can sleep soundly at night knowing I've saved precious picoseconds not flipping to cpu order.


Most CPUs suitable to implement such a protocol can do endian swapping for free e.g. a load+bswap instruction, a microarchitecture that fuses load+bswap. Don't worry about byte swapping fixed sized int across the network. Just keep in mind that for some applications it maters e.g. most bignum operations favour little endian, but databases profit from big endian (memcmp sorts in numerical order).


Huh, good to know. I guess the only other downside is actually making the compiler do the bswap depending on the language. Eg C has some weird compiler specific builtin keywords vs zig has a nice packed struct that does it for you.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: