Skip to content

Comment on Endian wars and anti-portability: this again?

Comments

Reminder that the computer's endianness shouldn't matter. You should only care about the endianness of the streams your reading from and writing to.

https://commandcenter.blogspot.com/2012/04/byte-order-fallac...

That should have been true, but unfortunately the most popular programming languages do not have distinct data types for bit strings, non-negative numbers, integer residues a.k.a. modular numbers, binary polynomials and binary polynomial residues.

So in C and the like one uses "unsigned" regardless if bit strings or non-negative numbers are needed.

Because no explicit conversions between bit strings and numeric types are used, it is frequent to have expressions where a certain endianness of the numbers is assumed implicitly.

This is the most frequent source of bugs that manifest when a program is run on a machine with an opposite endianness than assumed in the program.

This. In the specific case of endianness, if you have bugs with it you're probably already doing something wrong. But in general, supporting weird architectures is not something that should be expected to be foisted on any arbitrary projects, especially if the person who does the initial port just disappears again.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.