←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
515 points bwidlar | 8 comments | | HN request time: 0.661s | source | bottom
Show context
eqvinox ◴[] No.41858531[source]
> The storage order, the endianness, as given for my machine, is called little-endian. A system that has high-order representation digits first is called big-endian. Both orders are commonly used by modern processor types. Some processors are even able to switch between the two orders on the fly.

Calling big endian "commonly used by modern processor types" when s390x is really the only one left is a bit of a stretch ;D

(Comments about everyone's favorite niche/dead BE architecture in 3… 2… 1…)

replies(7): >>41858643 #>>41858658 #>>41858663 #>>41859666 #>>41860712 #>>41860854 #>>41866505 #
1. legends2k ◴[] No.41860712[source]
Arm is bi-endian and is alive in most phones.

I agree with another GP's comment that modern doesn't mean popular/widely used.

replies(3): >>41860723 #>>41860906 #>>41861026 #
2. umanwizard ◴[] No.41860723[source]
I really doubt any mainstream smartphone runs their Arm chip in big-endian mode ever.
replies(1): >>41860761 #
3. legends2k ◴[] No.41860761[source]
That's besides the point. The book's author has a valid point. Being pedantic should be applied at all levels if you're going that route.
replies(1): >>41861150 #
4. kelsey98765431 ◴[] No.41860906[source]
MipsBE is very common in edge devices on many networks. You may have 5 MipsBE devices in your home or office without realizing. It's almost never an issue so nobody cares, but they are common.
5. unscaled ◴[] No.41861026[source]
The book does say "Both orders are commonly used by modern processor types". I'd say this sentence is quite misleading, since it would lead you to believe two falsehoods:

1. That both byte orders are equally prevalent in the wild, particularly in systems that are expected to run modern C code.

2. That both byte orders are equally likely to be found in "modern" (new or updated) processor design.

It's not entirely incorrect, but a better phrasing could be used to clarify that little-endian is the more modern and common storage order, but you still cannot ignore big-endian.

replies(1): >>41862405 #
6. eqvinox ◴[] No.41861150{3}[source]
The problem about being pedantic is that you can choose different directions to be pedantic in. My "direction" is that code isn't written in a vacuum, it mixes with code millions of other people wrote and runs on machines millions of other people built. As such:

My concern isn't that the phrasing in the book is wrong, and I have expressly not argued that. It's that it presents the issue as having no further depth, and these two choices as equivalent. They aren't. The "Some processors are even able to switch between the two orders on the fly." that follows makes it even worse, at least to me it really sounds like you needn't give any care.

And the people reading this book are probably the people who should be aware of more real-world background on endianness, for the good of the next million of people dealing with what they produced.

7. 3836293648 ◴[] No.41862405[source]
Don't a bunch of web protocols use big endian?
replies(1): >>41865503 #
8. nineteen999 ◴[] No.41865503{3}[source]
You can go lower than that, TCP/IP itself is big-endian (see RFC 1700).