4 ms·
> Meaning, I'm not sure what the developer was thinking A 32bit integer is pretty much the default numeric type for the majority of programming tasks over the
by wvenable 9y ago
> Meaning, I'm not sure what the developer was thinking
A 32bit integer is pretty much the default numeric type for the majority of programming tasks over the last 20 years. Even with 64bit CPUs, 32bit is still a common practice. Probably 99% of all programmers would make the same choice unless given specific requirements to support more than 2 billion values.
- xapata 9y ago> 99% of all programmers Many dynamically typed languages have an automatic change from int to bigint rather than allowing overflow. For example, Python.
- mort96 9y agoOthers, like JS and Lua, just use doubles, meaning they'll never overflow - instead every 2 numbers start to be considered equal. Then a while after that every 4, etc. Not exactly optimal behavior when using incrementing IDs.
- tripzilch 9y agohowever, doubles represent integers accurately up to 53 bits. so that's still quite a lot before you run into that problem.
- ewjordan 9y agoIt's often not even an explicit choice, it's just default behavior. Up until recently, Rails defaulted to 32 bit IDs, so there are a ton of apps out there that could have these issues, especially since Rails has always prided itself on providing sane defaults: https://github.com/rails/rails/pull/26266 https://github.com/rails/rails/pull/26266