4 ms·
I still recall the shock discovering that Micro-soft BASIC in the Apple ][ did a linear search for the line number from, the beginning of the program, on each G
by ncmncm 7y ago
I still recall the shock discovering that Micro-soft BASIC in the Apple ][ did a linear search for the line number from, the beginning of the program, on each GOTO or GOSUB. It would have been super-easy to memoize the search result at the branch site, but Bill couldn't be bothered.
- fortran77 7y agoIn fact you could poke around and get the line numbers in a different order and the program would still run properly. That's why subroutines were put at the beginning of "efficient" code.
- sitkack 7y agoThis is cool. I feel like this has implications in metaprogramming, code generation, state machines, interposition, and stuff I haven't thought of. This changes my understanding of the semantics of basic immensely.
- ncmncm 7y agoSorry, it is not cool at all. A system that runs subroutines faster according to how far they are from the start of the program is just badly designed. Robustness against poking in different line numbers is not worth trading off performance. He should be ashamed.
- quicklyfrozen 7y agoDoesn't sound that easy to me. You'd need an efficient way to forget all those memoized values on each program edit, and every byte of program storage counted when memory size was a whopping 4K.
- ncmncm 7y agoTrust me, it would be easy. They could all be erased on the first edit, in time not noticeable. Essentially the same code would have been in each interpreter, so written just twice. The space for the code to do it would be in ROM, so would not take up any of your precious 4k.
- PhantomGremlin 7y agoSneer all you want, Microsoft Basic was a reasonable achievement considering that: 1) it ran in under 4K bytes of memory on an Altair 8800. That means less than 4,096 bytes of memory. Not 4,096 Kilobytes or Megabytes. 4,096 bytes. 2) An enhanced version ran in under 8K bytes of memory. Less than 8,192 bytes. Let me repeat: less than 8,192 bytes. When you're fitting an entire BASIC interpreter in 8,192 bytes, you're not spending a lot of effort to memoize a search result. Bill had a lot on his plate at the time. The software started out on the Altair, but all sorts of manufacturers were soon beating the door down begging for versions for the Commodore PET, the Atari, and countless other computers. https://en.wikipedia.org/wiki/Microsoft_BASIC https://en.wikipedia.org/wiki/Microsoft_BASIC
- perl4ever 7y agoFrom what I've read, Microsoft BASIC was considered too bloated for a 4K machine, plus Bill Gates wrote an open letter to hobbyists and suggested they were all pirates, so a smaller BASIC was developed called "Tiny BASIC": "Tiny BASIC was published openly and later invented the term "copyleft" to describe this. This made it popular in the burgeoning early microcomputer market." https://en.wikipedia.org/wiki/Tiny_BASIC https://en.wikipedia.org/wiki/Tiny_BASIC
- ncmncm 7y agoIt did not fit in 4K on the Apple ][. PET and Atari were also 6502, like Apple, so mostly the same code. Altair and the others were 8080. So, only two interpreters. It was the same design on two instruction sets, with some simple customization per vendor. Some had a Z-80, with extra instructions available: using those made your program smaller, but slower. It is doubtful he did. That it was so short also meant there just wasn't much to it. Bill doesn't need your unpaid defense. He didn't make his $billions from BASIC. That just gave him a customer list.