I think that the type names in Rust are much better than the ones in C. I'd choose f64
over double
and u32
over unsigned int
or uint_32t
any day. Is there any reason (other than tradition) to use those counter-intuitive hard-to-learn names?
I know that names like short
and long
are architecture-specific, but doesn't that make the actual problem even worse? C is said to be "portable assembly", but in the assembly language you actually have to use the correct registers and sizes, which are defined by architecture, just as in C. Therefore I'm not sure how this actually helps us to produce better code (in terms of readability).
The only problem I could think of is about byte size. If byte isn't eight bits, then using bit-numbers in type names wouldn't be so clever. But then, why don't we use some clear names that tell us exact multiples of byte that the datatype contains, like sb (single byte), db (double byte), qb (quad byte)?
So, why do we use architecture-specific type names in C, even when it is not necessary?
stdint.h
if we care about the exact sizes.uint_32t
is architecture-specific, whileunsigned int
is architecture-agnostic. Some C-compliant computers (meaning a computer for which a compiler compliant with the C standard exists) do not have a 32 bit unsigned integer. On those computers, there is no such thing asuint_32t
, but there still is anunsigned int
type.int
,float
, anddouble
are counter-intuitive and hard to learn? Really?