top | item 36577866

(no title)

andikleen2 | 2 years ago

Having spent a lot of time porting 32bit system code to 64bit, I developed a dislike for these explicit types. It's a slippery slope to hard code your bitness with people making assumptions where size_t or pointers fit.

Now maybe if you're already 64bit that's fine (it's unlikely that we'll ever need 128bit, and code is unlikely to grow down), but for anything starting smaller it's a pain.

discuss

order

tialaramex|2 years ago

Huh?

Zig, like Rust, has two kinds of "primitive" numeric types, the kind which are an explicit size in bits (u8, i16, f64 and so on) and then the word size ones (isize, usize), which are whatever size is suitable for your target machine.

C gets this all muddled because it has named primitive numeric types but their meaning is imprecise, and then it uses a typedef to assign one of these (but you don't know which one) as the native word size. So maybe long is the same as your size_t, and C will just assume you know what you're doing when you write a long where you need a size_t - thus making your code non-portable.

dralley|2 years ago

Just because your code compiles on a new platform doesn't mean the prior assumptions of the prior behavior of the types remains valid.

duped|2 years ago

But it should, and that's what stricter typing can help with.

diarrhea|2 years ago

People are already working on a 128bit Linux kernel.

staunton|2 years ago

The sizes of floating point are growing "apart" in the AI space. Who's to say what might happen with sizes of types. Maybe it's great to use mostly u8 if you're controlling a worldwide asynchronous networked megacomputer.

saagarjha|2 years ago

They’re better than implicit assumptions that int is 32 bits.