Why languages should never reorder structs
1 points by mrunix
1 points by mrunix
The video does not really make a compelling case. As it states, you can get the same effect via an opt-in mechanism such as an annotation on the type.
An opt-in mechanism also makes it clearer where certain layout choices are deliberate instead of accidental. Otherwise, you're left to doing guesswork.
Automatic compact layout also means that you can group related fields together lexically while still reducing struct size.
I don't think the video makes a compelling case either.
If your layout matters (be it because of performance or FFI), then your code should reflect that, and something like #[repr(C)] is a good thing (and ideally there is documentation explaining why it matters also).
I don't think FFI needing explicit struct layout control is a compelling argument against automatic field reordering either? Most structs in a given Zig or Rust program aren't going to be C structs, they're going to be Zig/Rust structs.