logoalt Hacker News

jdw64today at 1:25 PM1 replyview on HN

>The number of data formats I see that miss obvious things like alignment etc.

After reading that sentence, I felt a little guilty. It's actually a basic principle of design, but in practice, I just don't pay much attention to it and only write code for readability


Replies

benj111today at 2:52 PM

It doesn't even have to impact readability.

See for example

https://github.com/MayaPosch/NymphRPC/blob/master/doc/nymphr...

There's an int8 in the middle of int32s knocking everything out of alignment. And it doesn't need to be because flags is int32 and only uses 4 bits.

Changing that doesn't have to impact readability. Makes it easier to process, makes a struct representation more compact.