I can't believe how much of my pre #rust life I spent with only numbers that could be negative, instead of "this will absolutely not go below 0".
I should really consider starting to use the NonZero* types, too, but I've never really had an obvious opportunity to...
Anyway, here's to staying positive.
@zkat It honestly drives me nuts how, even in languages like C and C# that have unsigned types, no one bloody uses them. Like .NET is filled with things that are Int32 but should be UInt64 (even well after 32 → 64). I think it's partly the culture of Rust to be precise, not just the language?
@cgranade these days I get very very confused when I see an api that uses signed ints, because it makes me wonder if they’re using -1 as a sentinel, which I hate
@zkat I'm honestly not sure what's worse, using it as a sentinel or just using signed ints for lolz and hoping people guard against < 0 correctly.
@cgranade @zkat I don't know what it's worth to you, but Google's C++ style guide https://google.github.io/styleguide/cppguide.html#Integer_Types goes into why they're opposed to the use of unsigned integers, and that explicitly checking for > 0 is preferred.
@ilyvion @zkat That seems like such a weird argument to me. If you have a value where it is always a bug for it to be less than zero, why include negative numbers in the domain of that value's type? If there's something else like wraparound, solving it by using the wrong type feels very suboptimal by comparison to using checked arithmetic. Seems like they're effectively using negative numbers as a hack to get checked arithmetic in, but that's a disaster and a half waiting to happen...