3 ms·
> all integers are little-endian They really should be big-endian, because that’s network byte order. IMHO it makes sense to use decimal-encoded ASCII digits
by eadmund 2y ago
> all integers are little-endian
They really should be big-endian, because that’s network byte order.
IMHO it makes sense to use decimal-encoded ASCII digits instead and keep the protocol readable. Nothing like ‘telnet host.example 80’ followed by ‘GET / HTTP/1.0.’
> (1 bit) request_type: integer representing type of request
With two types already defined. No room for future extensions, then. Is the idea to just use another protocol altogether if change is necessary?
- drdaeman 2y agoI love how the term "endianness" was picked straight from Gulliver's Travels. It's a very good fit - old wise computer wizards must've known how it's gonna be.
- BoppreH 2y agoI'm not sure. I was confused for years thinking that "big-endian" meant "the big number is at the end". It was only after reading Gulliver's Travels that it clicked. I'm all for silly names, but I think this one went a little too much into obscure references and metaphors.
- wbl 2y agoThe RFC makes the reference explicit. https://www.rfc-editor.org/ien/ien137.txt https://www.rfc-editor.org/ien/ien137.txt
- kuroguro 2y agoI 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.
- crest 2y agoMost 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).
- kuroguro 2y agoHuh, 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.
- IshKebab 2y ago> because that's network byte order. That's not a good reason. It's the byte order used for some network protocols, but definitely not all. And given that protocols aren't interchangeable there's no advantage from having all protocols use the same endianness. Little endian makes way more sense today because all modern computers are little endian. The network itself doesn't care what you use. It's just a stream of bytes to the network.
- lxgr 2y ago> Nothing like ‘telnet host.example 80’ followed by ‘GET / HTTP/1.0.’ The 80 in port 80 is not ASCII encoded on the wire. That's an UI feature of telnet and/or your OS. (The 1.0 in HTTP is, though.)
- wang_li 2y agoI think they were more references the human readability of HTTP/1.0 in general instead of binary encoded data.
- eadmund 2y ago> I think they were more references the human readability of HTTP/1.0 in general instead of binary encoded data. Yup! You’re exactly right. I honestly thought that was obvious in context. There’s something just right about being able to manually connect to a web server and run queries against it, with very little in the way of tooling to do so. Technically, of course, both telnet(1) and nc(1) are tools, and even one’s TCP/IP stack and OS are, too, which is why I write ‘very little.’ It’s a heck of a lot fewer tools, and more general tools, than JSON-over-HTTP or RTP prober. And — please — do not refer to me as ‘they.’ I am not a collective, but rather a human being. I find being referred to as ‘they’ to be profoundly offensive.
- wang_li 2y agoPrior to recent years, the singular they was more often used as the generic pronoun. I'm old. No offense was intended. https://en.wikipedia.org/wiki/Singular_they https://en.wikipedia.org/wiki/Singular_they
- try_the_bass 2y ago> And — please — do not refer to me as ‘they.’ I am not a collective, but rather a human being. I find being referred to as ‘they’ to be profoundly offensive. I can't seriously believe you're not trolling with this. The use of singular "they" to refer to an individual of unknown gender has been a thing for literally centuries. Some people, like me, grew up on the Internet assuming every person they interacted with was male by default, because it was a statically sound assumption. We would then use the right pronoun if corrected (unless we thought you might be a G.I.R.L.) Some people, like the person you're ostensibly trolling, do not make this assumption, and just use the singular, gender-neutral "they", which is arguably the nicer, more humane approach anyway. Being offended by such an approach just smacks of trying to "own the libs", or just otherwise bring contrarian for the sake of it. Neither involves being genuinely offended by anything, and is instead a transparent piece of performative posturing. Please don't bring that here.
- mkj 2y agoNetwork byte order isn't a good reason for big endian. The most compelling reason for big endian is that it's easier to read in hex dumps.