3 ms·
Does that mean there are no file formats thatbuse big endian? And network byte order isn't a thing?
by jstimpfle 3mo ago
Does that mean there are no file formats thatbuse big endian? And network byte order isn't a thing?
- teravor 3mo ago> there are no file formats thatbuse big endian if someone chooses to do that they own the problems. > network byte order isn't a thing if the network serializes/deserializes for you (kernel primitives) then you don't care what it does. if it doesn't and for some reason you choose to use big endian, again, you own the problem.
- dcrazy 3mo agoIf someone chooses to load a TIFF or a PSD or an AIFF or…
- teravor 3mo agothen you either use an existing C library (the most likely approach) or if you are determined to re-implement it you have to be careful parsing their bytes.
- lkjdsklf 3mo agoNetwork byte order has nothing to do with the kernel and you have to care about it It’s a standard because neither side of the connection knows the endianness of the other side so there must be a standard. That standard is big endian regardless of your architecture or kernel or anything else So any serialization intended go over the network should be big endian
- teravor 3mo agoright, so a zig app will just do little endian. in the very unlikely event you have it running on a big endian machine you have to do extra work.
- jstimpfle 3mo agoYou may have never done socket programming, or do you use wrapper libs in Zig? Because you have to send the kernel big endian port numbers for example. What do you do if you program a kernel in Zig, or just generally do low level networking? My point is to refute the statement that everyone has agreed to little endian, and so there aren't use cases to want to do conversion. Programs do not exist in a vacuum, most programs do not.
- chongli 3mo agoAnd what happens if your zig app happens to be a network driver running on a microcontroller?
- charcircuit 3mo agoGenerally those edge cases are always the same endianness. You don't need big and little endianness versions of the structures. What's important is that everyone agrees on the same thing.
- nextaccountic 3mo agoThere are some cursed data formats where something is little endian in some places, big endian in other places Generally speaking though the types you handle in business logic (what your application actually do) shouldn't have any endianness