3 ms·
> What exactly do you dislike about this? Or what do you even do about it? A handful of solutions already exist: - Use a higher-level language - Java
by rusk 8y ago
> What exactly do you dislike about this?
Or what do you even do about it?
A handful of solutions already exist:
- Use a higher-level language
- Java
- Dylan16807 8y ago> Or what do you even do about it? All you need is a list of what width each type is. > A handful of solutions already exist: - Use a higher-level language - Java It doesn't require being "higher level". If anything it pushes code to a slightly lower level.
- rusk 8y ago> All you need is a list of what width each type is. This is exactly the kind of minutiae that GP was bemoaning. > If anything it pushes code to a slightly lower level Yeah by way of higher-level abstractions ...
- bfrydl 8y ago> This is exactly the kind of minutiae that GP was bemoaning. How is this “minutiae”? You should always know the possible range of a numeric variable or field when you create it, so why not just write what size it is? In Rust the main numeric types look like this: i32, u64, u8. You just pick the one you want.
- kiriakasis 8y agothe main numeric type is usize
- steveklabnik 8y agoThat’s not correct, it’s i32. usize has a specific purpose: when you need a length of something in memory.
- shittyadmin 8y agoThe entire idea of a "main numeric type" is sort of silly - know what data you're dealing with and pick the length accordingly!
- steveklabnik 8y agoYeah, I only say "main" here because it's what you should pick if you're not sure.
- rusk 8y agoI'm sorry, I misunderstood you. These typedefs as I'm used to them do address cross-platform issues. Storage classes are "minutiae" however when all you want is just a straight up number. Python gives me an Integer type when I want a whole number, or a Float when I want to represent partials. I don't really care to be honest how that gets represented in memory in this case.
- Dylan16807 8y agoA float in Python is an implementation-specific size, just like C. So I'm really confused about using it as an example here. > Storage classes are "minutiae" however when all you want is just a straight up number. You can have a single "straight up number" and mention the bit width in the language spec. The mere act of writing it down doesn't force coders to deal with any more minutiae than they already had to deal with. > Yeah by way of higher-level abstractions ... I strongly object to this. "float is at least x bits" and "float is exactly x bits" are the same level of abstraction, and almost every language, high or low level, picks one of those options.
- rusk 8y agoYou can strongly object all you want, but when I'm writing code in python, or any other high-level language I don't care one jot about storage size.
- Dylan16807 8y agoYou could apply that same "who cares?" attitude to the size of "double" in C. Whether you burden yourself with that knowledge is not a feature of the language. More "C coders" care because they're micro-optimizing, but it's no more needed in C than Python. Also you named Java as being on the easy side and that has four different integer sizes...
- rusk 8y agoNo ... not really. Double doesn't behave like a whole number. java only has a single int type, which is 32-bit regardless of machine architecture.