6 ms·
The mental image conjured up by this scenario is amusing. Your impossibly patient party waits almost 15,000 years to cross a river in a state of suspended anim
by jandrese 2y ago
The mental image conjured up by this scenario is amusing. Your impossibly patient party waits almost 15,000 years to cross a river in a state of suspended animation. Then they finally cross the river and instantly wither away to dust because they had not had a good meal in 15 centuries.
Something that was very common with BASIC interpreters but still baffling is how they were running on machines with extremely limited memory and fairly limited CPU time, but for some reason decided not to make integer types available to programmers. Every number you stored was a massive floating point thing that ate memory like crazy and took forever for the wimpy 8 bit CPU with no FPU to do any work on. It's like they were going out of their way to make BASIC as slow as possible. It probably would have been faster and more memory efficient if all numbers were BCD strings.
- davedx 2y agoSounds like JavaScript!
- em3rgent0rdr 2y agoaround 1999 when I stumbled upon JavaScript I was aghast that numbers were always 64-bit floating point. I thought that language would go nowhere.
- Mountain_Skies 2y agoMost of the 8-bit BASICs of the time share a common ancestor. Perhaps making every number a floating point was a reasonable decision for the hardware that the common ancestor BASIC was written for and it just got carried over through the generations.
- jandrese 2y agoI think it's more likely that the language had no concept of types so number had to "just work". You can do integer math (slowly) using floating point, but you can't do floating point math with integers. Especially since the language is targeted at beginners who don't really understand how their machines work. Would have been interesting to see a version of BASIC that encoded numbers as 4 bit BCD strings. Compared to the normal 40 bit floating point format you would save memory in almost every case, and I bet the math would be just as fast or faster than the floating point math in most cases as well. The 4 bit BCD alphabet would be the numbers 0-9, as well as -, ., E, and a terminator and a coupld of open numbers if you can think of something useful. Maybe an 'o' prefix for octal and a 'b' for binary?
- canucker2016 2y agoIf you look at the ads for microcomputer software, there were a lot of business-related stuff, i.e. AR, AP, etc. Stuff that a kid in public school had no idea what those acronyms meant. If you're writing business software, you'll need to support decimals for currency-related calculations. Tax and interest rates also require decimal values. So floating point helped a lot. When the 8-bit microcomputers went mainstream, (Apple II, Commodore PET, TRS-80), graphics got more popular - sin(), cos(), and other trig functions are popular and their return values are never normally expressed as integer values. Sure, most would never write a fast arcade-like game in BASIC, but as a code trial playground, turnaround time was relatively quick.
- glonq 2y ago...except that using floating-point values to represent currency was never recommended because of precision issues. Using fixed-point or "integer cents" was preferable.
- hdhdbebd 2y agoI don't understand your argument Especially when doing financial calculations you do not want to use floating point but fix point O_o
- jandrese 2y agoYou want to try to explain fixed point math to someone who is for the first time discovering the concept of a "variable"?
- wizzwizz4 2y agoIt only lets you store whole pennies, not fractions of a penny. This is to help stop rounding errors accumulating, and eventually making a calculation wrong. With fixed point, if you put the formula in right, there will be no surprises.
- HeyLaughingBoy 2y ago
- NikkiA 2y agoMostly that ancestor would be MS Basic on the altair.
- nopakos 2y agoI remember having integer variables in Amstrad CPC (Locomotive) Basic. Something with the % symbol. edit: ChatGPT says that BBC BASIC and TRS-80 Microsoft BASIC also supported integer variables with % declaration.
- canucker2016 2y agoThe wikipedia page for Microsoft BASIC (which Applesoft Basic is a variant), https://en.wikipedia.org/wiki/Microsoft_BASIC https://en.wikipedia.org/wiki/Microsoft_BASIC, mentions that integer variables were stored as 2 bytes (signed 16-bit) but all calculations were still done in floating point (plus you needed to store the % character to denote an integer var). So the main benefit was for saving space with an array of integers.
- sedatk 2y agoYes, Locomotive BASIC also supported DEFINT command, so, all variables in a given range would be treated as integers without "%" suffix.
- mywittyname 2y ago> but for some reason decided not to make integer types available to programmers. Can you expand upon this? All of the research I've done suggest that, not only was it was possible to use integer math in Basic for the Apple II, there are versions of BASIC that only support integers.
- Salgat 2y agohttps://en.wikipedia.org/wiki/Dartmouth_BASIC https://en.wikipedia.org/wiki/Dartmouth_BASIC "All operations were done in floating point. On the GE-225 and GE-235, this produced a precision of about 30 bits (roughly ten digits) with a base-2 exponent range of -256 to +255.[49]"
- jazzyjackson 2y agoGood find, Dartmouth was the original BASIC for their mainframe timesharing, Apple and other micro variants came later. Speaking of, John G. Kemeny's book "Man and the Computer" is a fantastic read, introducing what computers are, how time sharing works, and the thinking behind the design of BASIC.
- jandrese 2y agoBASIC 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.
- deleted 2y ago[deleted]
- glxxyz 2y agoBBC BASIC from Acorn in 1982 supported integers and reals. From page 65 of the user guide [https://www.stardot.org.uk/forums/download/file.php?id=91666 https://www.stardot.org.uk/forums/download/file.php?id=91666] Three main types of variables are supported in this version of basic: they are integer, real and string. integer real string example 346 9.847 “HELLO” typical variable A% A A$ names SIZE% SIZE SIZE$ maximum size 2,147,483,647 1.7¥1038 255 characters accuracy 1 digit 9 sig figs — stored in 32 bits 40 bits ASCII values A%, A, and A$ are 3 different variables of different types.
- deleted 2y ago[deleted]
- CalRobert 2y agoAnd to add insult to injury, you write "peperony and chease" on their tombstone. Edit: Poor Andy :-( https://tvtropes.org/pmwiki/pmwiki.php/Trivia/TheOregonTrail https://tvtropes.org/pmwiki/pmwiki.php/Trivia/TheOregonTrail
- dcrazy 2y agoInterestingly enough, the article notes that this program was written for Microsoft’s AppleSoft BASIC, but Woz famously wrote an Integer BASIC that shipped on the Apple II’s ROM.
- skissane 2y agoWoz planned to add floating point support to his Integer BASIC. In fact, he included a library of floating point ROM routines in the Apple II ROMs, but he didn't get around to modifying Integer BASIC to use them. He ended up working on the floppy disk controller instead. When he finally got around to doing it, he discovered two issues – Integer BASIC was very difficult to modify, because there was never any source code. He didn't write it in assembly, because at the time he wrote it he didn't yet have an assembler, so he hand assembled it into machine code as he worked on it. Meanwhile, Jobs had talked to Gates (without telling him) and signed a deal to license Microsoft Basic. Microsoft Basic already had the desired floating point support, and whatever Integer BASIC features it lacked (primarily graphics) were much easier to add given it had assembly code source. https://en.wikipedia.org/wiki/Integer_BASIC#History https://en.wikipedia.org/wiki/Integer_BASIC#History I was thinking about this the other day, I wonder if anyone has ever tried finishing off what Woz never did, and adding the floating point support to Integer BASIC? The whole "lacking source" thing shouldn't be an issue any more, because you can find disassemblies of it with extensive comments added, and I assume they reassemble back to the same code.
- scarface_74 2y agoThe Apple //e ROMs had AppleSoft BASIC. Integer basic could be loaded from the original DOS disks
- dcrazy 2y agoAccording to Wikipedia, the original Apple II ROM had Integer BASIC. Apple licensed AppleSoft in response to customer demand for a floating point BASIC, and it became the in-ROM BASIC for the Apple IIc and IIe.
- 2y ago
- gitremote 2y ago[dead]
- Brian_K_White 2y agoMS BASIC on TRS-80 model 100 default, a normal variable like N=10, is a signed float that requires 8 bytes optional, add ! suffix, N!=10, is a signed float that requires 4 bytes optional, add % suffix, N%=10, is a signed int that requires 2 bytes And that's all the numbers. There are strings which use one byte per byte, but you have to call a function to convert a single byte of a string to it's numerical value. An unsigned 8-bit int would be very welcome on that and any similar platform. But the best you can get is a signed 16-bit int, and you have to double the length of your variable name all through the source to even get that. Annoying.
- deleted 2y ago[deleted]
- em3rgent0rdr 2y ago> "for some reason decided not to make integer types available to programmers...It's like they were going out of their way to make BASIC as slow as possible." BASIC was well-intention to make programming easy, so ordinary people in non-technical fields, students, so people who weren't "programmers" could grasp. In order to make it easy, you better not try to scare adopters with concepts like int vs float and maximum number size and overflow, etc. The ordinary person's concept of a number fits in what computers call a float. You make a good point though that BCD strings might have done the trick better as a one-size fits all number format that might have been faster. BASIC also wasn't intended for computationally intense things like serious number crunching, which back in the day usually was done in assembly anyway. The latency to perform arithmetic on a few floats (which is what your typical basic program deals with) is still basically instantaneous from the user's perspective even on a 1 MHz 8-bit CPU.
- scarface_74 2y agoThe 6502 ironically enough did support BCD strings directly http://www.6502.org/tutorials/decimal_mode.html http://www.6502.org/tutorials/decimal_mode.html
- leni536 2y agoMaybe it was a consideration of code size. If you already choose to support floats then you might as well only support floats and save a bunch of space by not supporting other arithmetic types.
- paulddraper 2y agoIt’s like knew how popular JS would be someday.
- RiverCrochet 2y ago> but for some reason decided not to make integer types available to programmers They were there, you had to append % to the variable name to get it (e.g. A% or B%, similar to $ for strings). But integers were not the "default." BASIC is all about letting you pull stuff out of thin air. No pre-declaring variables needed, or even arrays (simply using an array automatically DIM's it for 10 elements if you don't earlier DIM it yourself). Integer variables on BASIC were 16-bit signed so you couldn't go higher than 32767 on them. But if you are going to use your $500 home computer in 1980 as a fancy calculator, just learning about this newfangled computer and programming thing, that's too limiting. I do remember reading some stuff on the C64 that its BASIC converted everything to floating point anyway when evaluating expressions, so using integer variables was actually slower. This also includes literals. It was actually faster to define a float variable as 0--e.g. N0=0--and use N0 in your code instead of the literal 0. Floats were 5 bytes in the early 80's Microsoft BASICs, honestly not "massive" unless you did a large array of them. The later IBM BASICs did have a "double precision" float that was 12 bytes maybe? > It probably would have been faster and more memory efficient if all numbers were BCD strings. I wouldn't be surprised if Mr. Gates seriously considered that during the making of Microsoft BASIC in the late 70's as it makes it easy for currency calculations to be accurate.
- arccy 2y agothat would be 15 millennia or 150 centuries
- cjbprime 2y ago> Something that was very common with BASIC interpreters but still baffling is how they were running on machines with extremely limited memory and fairly limited CPU time, but for some reason decided not to make integer types available to programmers. To be fair, JavaScript suffers from the same laziness :)