this isn't about implicit conversion, it's about the fact that javascripts default number type isn't a 64-bit integer.
And yes, i do have the same complaint about C and C++ but at least you can argue about memory efficiency of using a 32-bit integer when it comes to those 2.
I think the problem with C is that it was originally designed for machines that aren't relevant anymore.
Back in the days of C being invented, memory was word-addressed. Integers smaller than a word had to be implemented by bit manipulation. C was very much defined so that int could be a word, so programs using int got good performance.
On modern architectures, there isn't really a single defined "word size", pretty much all the integer sizes up to 64-bit are the same performance, with the main performance differences between integers being memory reads/writes and how many you can fit in a packed SIMD register. So compiler authors just map char, short, int, long, and long long in a way that gives access to all the different supported sizes.
If you look at modern systems languages (Rust, Zig, etc), you'll notice that they use integer names like u32 or i64. In fact, the stdint.h header (added in C99 and C++11) defines fixed-width integers in C and C++ (e.g, uint32_t, int64_t, etc), and some coding standards for C and C++ mandate the use of fixed-width integers.
View all comments
Show parent comment
1
u/definitelynotagirl99 Jul 18 '24 edited Jul 18 '24
this isn't about implicit conversion, it's about the fact that javascripts default number type isn't a 64-bit integer.
And yes, i do have the same complaint about C and C++ but at least you can argue about memory efficiency of using a 32-bit integer when it comes to those 2.
edit: grammar