It definitely isn't[1]. Python has both floats and integers. He's sort of right though that it doesn't have "true integers ... which ... improve performance" since Python's numeric types are boxed and not exactly fast (unless you use numpy).
Also, which "many other" languages have only doubles, aside from JavaScript?
[1] https://docs.python.org/3/reference/datamodel.html#the-stand...
Re:James Gosling Interview
by mananaysiempre on Thursday August 12, 2021 @07:13AM
(#28154799)
Lua < 5.3 (thus also LuaJIT), unless you make an integer-only build. But yes, I wouldn’t call that “many”.
Re:James Gosling Interview
by oldprogrammer2 on Thursday August 12, 2021 @11:33AM
(#28157615)
I would guess he might be talking about how integers are objects in python, and stored in heap, rather than being stored as values directly on the stack. I haven’t looked, but it could also be in python that all numeric types are stored according to IEEE 754 before being unboxed to the indicated type.
Re:James Gosling Interview
by martincmartin on Thursday August 12, 2021 @08:50AM
(#28155589)
Edit: I said Tcl, but that has the opposite problem: integers are fine, but floating point is problematic because everything is strings. Updated below to remove Tcl.
I don't think this is true of most languages; only for Lua that I know of. And it causes problem: if you send a 64-bit ID to Lua, which represents it as a double, it will subtly change the last few bits. Then when you go to look up something with that ID, you get the wrong item.
Most languages don't have that problem.
I don't know much about Tcl, but I thought everything was a string, not a float? It appears to work with integers just fine:
$ echo 'puts [expr 2 ** 128 + 1]' | tclsh
340282366920938463463374607431768211457
$ python3 -c 'print(2 ** 128 + 1)'
340282366920938463463374607431768211457
$ node -p 'Math.pow(2, 128) + 1'
3.402823669209385e+38Tcl hasn't been string based for 20 years, misinformation is hard to eliminate. Since the release of version 8.0 in 2001, Tcl internally has value types for integer, bigints, double, boolean, lists, etc.. As long as you're careful not to cause the internal value to 'shimmer' into a string representation, Tcl maintains the value type as last used. Tcl happily converts values to strings as needed, giving the impression of 'everything is a string'.
Re:James Gosling Interview
by martincmartin on Thursday August 12, 2021 @09:49AM
(#28156314)
Yeah good point, I updated my comment. Thanks!
Re:James Gosling Interview
by secondcoming on Thursday August 12, 2021 @08:56AM
(#28155658)
Yes, I couldn't believe Lua chose this path. We have to use Lua scripts with Redis and this conversion stuff concerns me.
Re:James Gosling Interview
by kevin_thibedeau on Thursday August 12, 2021 @12:12PM
(#28158077)
Tcl hasn't been string based for 20+ years. It used boxed objects ever since the bytecode interpreter was added in 8.0.
It’s a pedantic statement. Correct for the base language, but numpy supports 16, 32, 64, and maybe extended/128 bit too. It’s the kind of nonsense argument from language flamewars that has no relevancy for practical use cases.
Anyway, java does not have unsigned int, so there you go.
Edit: if he claims that int-is-float like in javascript, he’s just flat wrong.
Re:James Gosling Interview
by WoodenChair on Thursday August 12, 2021 @08:31AM
(#28155399)
“It’s a pedantic statement. Correct for the base language”
No, it’s not. In the base language Python has an int type that is separate from its float type.
See numbers.Integral and numbers.Real
I don't think that's correct for Python!