5 ms·
Does any of the programming languages Guy Steele worked with do the former and not the latter? Java certainly doesn't: https://godbolt.org/z/b847KeaGv https://
by bhaak 2y ago
Does any of the programming languages Guy Steele worked with do the former and not the latter?
Java certainly doesn't: https://godbolt.org/z/b847KeaGv https://godbolt.org/z/b847KeaGv
There's a good reason for this. Computer numbers are not the same as numbers in mathematics. Floating point numbers are not real numbers and ints are not natural numbers.
- guenthert 2y agoScheme, Common Lisp. Neither Java nor CL were intended for the novice; I'm sure Mr. Steele had Scheme in mind.
- bhaak 2y agoI think there is also a gotcha there as you get a ratio in Common Lisp and not a floating point number. > (print (format t "1 divided by 2 is ~a and its type is ~a" (/ 1 2) (type-of (/ 1 2)))) > 1 divided by 2 is 1/2 and its type is RATIO I don't think there is a simple solution. Numbers are harder than they seem and you just need to know what happens in the particular language you are programming in.
- regularfry 2y agoArguably that's not a gotcha. It's (probably) his point.
- mihaaly 2y agoIt was not debated that there is no reason some languages behave one way or the other - it is quite the opposite - only that for supporting the pratical use cases - which is the sole purpose of any language, to be useful for practical cases - then it is not a good reason. When one has to jump hoops of the language - being the user for the whims of the language and not the language for the user - that is wasting efforts and adding complications instead of helping. Being more like puzzle for fun that practical application. Those want to keep close to the soul of the hardware and computing should use C or other low level languages, existing for long. Not made recently to make programming easier ... on paper only apparently...
- bhaak 2y agoPretty harsh words for an issue that is not really language specific. Numbers are not as easy as they seem. Computer numbers are not the same as the numbers from mathematics. Is "0.5" supposed to be a floating point number or a rational data type? What about conversion of types? Sometimes you just need to know what happens in the particular language you are programming in.
- mihaaly 2y agoThere is no computer numbers and mathematical numbers, there are only mathematical numbers and the limited (failed by circumstances) representation of mathematical numbers existing for low level lenguages since the ancient times of computing. Which should be improved - failed representation eliminated - wherever and whenever possible. Especially for new languages. And since there are better and worse representations - actually handling - of numbers accross the languages the criticism of doing badly, not making improvements, expecting to know the whims of a modern lannguage in this regard is absolutely founded!