I have gained some sympathy for Design 1 through this discussion, but some things are still troubling me. None of them are particularly dispositive, but I really would appreciate some help working through them.
First off, while the people in this thread certainly don’t find the lack of an int type to be strange, and all have the right kind of experience to think carefully about integer sizes, I think that that may not be representative of the wider community, especially people who will join the Rust community after 1.0.
I’ve taken a straw poll of friends of mine in more HLL circles (but who have written a lot of code in C/C++/Java) who are keeping an eye on Rust. For them, the lack of any int type is indeed, pretty weird. They also found the name isize to be weird, but that specific detail is not crucial for this discussion.
I don’t know exactly how to represent this feeling, but I understand it, and I don’t think it’s being addressed that well in this thread. Most people here are all very well-versed in the details of this topic, which make you somewhat different from an everyday user, even one who understands the existence of various integer sizes (but doesn’t want to work at that level of abstraction every time they need an integer).
To be clear, I don’t think anyone disagrees that there are many times when you actually have some idea of the bounds of your integer, and where you want to use a fixed-sized iN. Much of my code uses explicit i32s and i64s, and that doesn’t bother me much at all. The question is more about what happens when you know you want an integer, but haven’t thought about how big it will need to be.
The existence of so many blind casts (to silence type errors) by even experienced developers leads me to believe that this state of mind (“I don’t really know what integer I need, but just make this work”) is more widespread that we might imagine.
Second of all, it seems like the core problem bedeviling us here is the mere existence of an isize type. That means that no matter what we do, if Vec deals in isizes, people will end up writing programs that are different across platforms.
In that light, the key question is how common isizes actually are, and how much they pollute other parts of the program. If isizes are relatively uncommon to be used explicitly (because they can often be inferred when used, for example, via enumerate), maybe having a fixed-sized int type that interacts awkwardly when used with explicit uses of isize isn’t so bad.
Finally, I also think I want to explore the precise problems with type int = i64 a little bit more, despite being initially negative towards it because of the problem of truncation. Nothing is stopping a user from choosing a smaller type if they know that the number they’re using fits into 32-bits, but 64-bits is both big enough for a huge amount of real-world domains and consistent across platforms.
In particular, I’m wondering whether we could improve the truncation problem though improved error messages: when attempting to use an i64 in an isize (like indexing), they would get an error that says that they have the wrong type, and explain that i64 is too big for 32-bit systems. It would suggest using an i32 or isize instead, and specifically discourage a cast.