3 ms·
BASIC doesn't have typing, so most BASIC interpreters just used floating point everywhere to be a beginner friendly as possible. The last thing they wanted was
by jandrese 2y ago
BASIC doesn't have typing, so most BASIC interpreters just used floating point everywhere to be a beginner friendly as possible.
The last thing they wanted was someone making their very first app and it behaves like:
Please enter your name: John Doe
Please enter how much money you make every day: 80.95
Congratulations John Doe you made $400 this week!
- int_19h 2y agoClassic BASIC does have typing, it just shoves it into the variable name. E.g. X$ is a string, X% is a 16-bit signed integer, and X# is a double-precision floating point number. This started with $ for strings in Dartmouth BASIC (when it introduced strings; the first edition didn't have them), and then other BASIC implementations gradually added new suffixes. I'm not sure when % and # showed up specifically, but it was already there in Altair BASIC, and thence spread to its descendants, so it was well-established by 1980s.
- JoshTriplett 2y agoInteresting. I wonder if this association of $ with strings is related to the use of $ (rather than NUL) as the string terminator for DOS output routines?
- mock-possum 2y agoI always just figured ‘$’ looks like S, and S is for String
- int_19h 2y agoPretty sure DOS got it from CP/M, but I'm not sure why the latter would have it. That said, it probably has something to do with earliest 5-bit and 6-bit text encodings that were very constrained wrt control characters, and often originating from punch cards where fixed-length or length-prefixed (https://en.wikipedia.org/wiki/Hollerith_constant https://en.wikipedia.org/wiki/Hollerith_constant) strings were more common. E.g. DEC SIXBIT didn't even have NUL: https://en.wikipedia.org/wiki/Six-bit_character_code https://en.wikipedia.org/wiki/Six-bit_character_code
- Breza 2y agoWhoa, I never realized this. And I spent much time in high school writing programs in QBASIC.
- Breza 2y agoIIRC Python had similar reasoning for making floats the default in version 3 instead of integers, which had been the assumption in 1 and 2 when you entered a number without a decimal. R always did it that way and Julia still assumes integer, which occasionally trips me up when switching languages.