Hacker News new | ask | show | jobs
by deathanatos 15 days ago
Rust has a compile time option, though to my immense disappointment, it defaults to on only in debug mode. (You can opt into it for release, if desired.)

Python simply can't overflow, since its integral type is not a fixed width.

But it is the sort of correctness thing that I do wish languages would pay more attention to.

2 comments

In Rust's case it just matters a lot less since bounds checks are still present. But I do think int under/overflows are probably one of the scarier issues in the language.
Overflows are dangerous by itself. Assume you keep the order total price as uint32. Someone orders a spaceship for 2.2B credits, and then adds another one which is not an expected scenario. The total counter overflows and now you have sold 2 expensive spaceships at 99% discount.
Yes, that is bad. No one is saying that all bugs require memory unsafety.
>Python simply can't overflow, since its integral type is not a fixed width.

Python master race

While I do think that was one of (maybe the only) really great decision Python made... There are so many other things wrong with it that it's a poor choice for almost anything in my book.