Three prevalent themes in the discussion
- Historical flexibility was essential for C’s portability and survival
- “C would probably not have survived unless it had this flexibility.” — quelsolaar
- “The C flexible integer sizes were still necessary at the time of its creation, when some important computers still had word sizes that were not powers of two.” — adrian_b
-
Many argued that C’s ability to map
int,long, etc. to the natural word size of wildly different architectures (from 16‑bit microcontrollers to 36‑bit mainframes) was a key reason it could be used everywhere. -
Flexible sizes create portability, correctness, and ABI problems; fixed‑width types are preferable
- “On modern computers, it is impossible to write correct C programs that are agnostic about the true size in bits of the ‘flexible’ types… those assumptions must be made explicit, by using types like int16_t, int32_t etc.” — adrian_b
- “For actually portable C code it was always better to use fixed-width integer types which were chosen for the problem to solve instead of target hardware capabilities.” — flohofwoe
-
Commenters highlighted issues like unexpected overflows, mismatched
size_t/pointer sizes, ABI mismatches, and the proliferation of#ifdefspaghetti when mixing traditional and fixed‑size types. -
Performance and backward compatibility justify keeping common types (like
int) 32‑bit even on 64‑bit systems, and using the fast/least variants when needed - “
intbeing 32‑bits on amd64 was the correct decision… Existing 32‑bit code just worked on the 64‑bit chip… compilers will emit 32‑bit versions of instructions when the upper 32‑bits are not needed, because it’s cheaper.” — sparkie - “On a modern computer, the ideal integer type is usually smaller than 64 bits… 64 bits take up twice the memory bandwidth, and half as many fits in a cache‑line.” — quelsolaar
- Several noted that using
int_fastN_t/int_leastN_tlets programmers express performance or storage requirements without tying themselves to the hardware’s word size.