predef icon indicating copy to clipboard operation
predef copied to clipboard

Endianness.md: "Avoid endianness whenever possible"

Open amitdo opened this issue 3 years ago • 7 comments

Avoid endianness whenever possible.

It is not clear what do you mean here.

amitdo avatar Sep 05 '22 08:09 amitdo

Not a great wording, I agree.

I think it means to write code without the need of relying on network or machine native endianness. Would be a great recommendation, but it's not really easy to just not deal with any type of binary data.

a1batross avatar Sep 05 '22 09:09 a1batross

It is a general design recommendation to avoid meddling with endianness. For example, to choose a textual exchange/serialization format instead of a binary format.

breese avatar Sep 05 '22 12:09 breese

If you need to store numerical data, it's recommended to use an established serialization library like Protocol Buffers or FlatBuffers, instead of using a custom binary format.

amitdo avatar Sep 05 '22 12:09 amitdo

I think we can mention using text representation or using protobuf and flatbuffers in the docs then? These two are good examples of serialization libraries for C/C++.

a1batross avatar Sep 05 '22 13:09 a1batross

I do not think we should recommend any particular binary protocol - they come and go.

The predef pages are intended for developers who implement the protocols, not the developers who use the protocols.

The recommendation in question is intended as a sanity check before you start implementing code that depends on endianness.

breese avatar Sep 05 '22 13:09 breese

I agree with @breese.

bagder avatar Sep 05 '22 13:09 bagder

Yes, I agree too.

Should this be closed then?

a1batross avatar Sep 05 '22 14:09 a1batross