The Broken BASIC Years – We Saw a Chicken …
The Broken BASIC Years
Written by
scruss
in
computers suck
I polled Mastodon people a few weeks back:
Twice as many people said their home computer’s BASIC did something illogical as said it did the right thing. What gives?
The de facto problem
BASIC was refined over several years in the mid-1960s as part of the Dartmouth Time-Sharing System (DTSS) running on a GE mainframe. It was intended to be accessible to all students at Dartmouth. Responsiveness to user commands was valued over performance. The concept caught on, and by 1970 DEC, HP, IBM and GE all had time sharing BASIC systems in the market.
The language was simple enough that if you’d used it before on another system, you’d have a good idea how it should look. Implementations of BASIC sprung up on lots of computer systems based on whatever documentation was at hand: if you were lucky, maybe a photostat of a Dartmouth BASIC manual, or maybe one of the programming manuals that DEC sold for their PDP-8 systems.
The original BASIC ran on a mainframe computer with each line being compiled into separate jobs by a terminal server. Early microcomputer developers, however, saw BASIC as something they could fit into a few thousand bytes as an interpreter. With so little space to work in, and so few guidelines to work from, implementation rules became very blurred. Here’s what you might have expected to see if you fired up your 8K Altair 8800 some time in 1976 after buying a shiny new (and $$) copy of Altair BASIC:
MEMORY SIZE? 8192<br>TERMINAL WIDTH? 80<br>WANT SIN-COS-TAN-ATN? N
1862 BYTES FREE<br>ALTAIR BASIC REV. 4.0<br>[EIGHT-K VERSION]<br>COPYRIGHT 1976 BY MITS INC.<br>OK<br>10 FOR X=3 TO 2 STEP 1<br>20 PRINT X<br>30 NEXT X<br>40 PRINT X<br>RUN<br>OK
With so little memory to play with, the FOR X=3 TO … is effectively treated as LET X=3, and NEXT X becomes LET X=X+1 (with an optional GOTO 20 if X 1975 Altair BASIC Manual has a slightly more lucid description on page 32, but doesn’t explain why it does this. Maybe it was influenced by FORTRAN-66, which always executed a DO clause once.
The only guidance against this admittedly illogical behaviour is hidden away on page 37 of the Dartmouth BASIC 4th Edition manual from 1968:
No, I can’t get past that the Os are slashed and the 0s are not, either
So in a feat of mass emulation (and sometimes using real vintage hardware), here are some BASIC systems that always execute a FOR loop at least once:
Altair BASIC 8K (version 4.0, 1976, Microsoft – 8080)
BASIC-E (version 2.0, 1976, Digital Research – 8080)
Tiny BASIC (version 3.1, 1976, Sherry Bros./Li Chen Wang – 8080)
BASIC-80 (version 4.51, 1977, Microsoft – 8080)
Commodore BASIC (1977, Microsoft – 6502)
Integer BASIC (1977, Apple – 6502)
TRS-80 Level I BASIC (1977, Radio Shack – Z80)
AppleSoft BASIC (version 2.0, 1978, Microsoft – 6502)
Atari BASIC (1979, Atari Inc. – 6502)
Atom BASIC (1980, Acorn – 6502)
Sinclair ZX80 BASIC (1980, Sinclair Research – Z80)
BASIC3 (version 1.1, 1981, RCA – 1802)
BBC BASIC (version 2, 1981, Acorn – 6502)
CBASIC (version 2.07, 1981, Digital Research – 8080)
Extended Color BASIC (version 1.1, 1982, Microsoft – 6809)
Lynx BASIC (1983, Camputers – Z80)
MSX BASIC (version 1.0, 1983, Microsoft – Z80)
MTX BASIC (1983, Memotech Ltd – Z80)
Oric Extended BASIC (version 1.1, 1983, Tangerine – 6502)
And these are the interpreters that handle FOR loop variables correctly:
PDP-8 BASIC (1970, DEC – PDP-8)
TOPS-10 BASIC (version 5.03, 1972, DEC – PDP-10 KA10)
9830 BASIC (1973, Hewlett-Packard – HP9800)
5100 BASIC (1975, IBM – PALM)
HP 2000/Access BASIC (version r.1534, 1975, Hewlett-Packard – HP2000)
BASIC-11/RT-11 (V02-03, 1978, DEC – PDP-11)
BASIC-80 (version 5.21, 1981, Microsoft – 8080)
IBM PC BASIC (version 1.10, 1981, Microsoft – 8088)
Sinclair ZX81 BASIC (1981, Sinclair Research – Z80)
Amstrad CPC464 BASIC (version 1.0, 1984, Locomotive Software – Z80)
BASIC for Macintosh (version 2.00, 1984, Microsoft – 68000)
Mallard-80 BASIC (version 1.29, 1984, Locomotive Software – Z80)
SuperBASIC (QL) (1984, Sinclair Research – 68000)
Extended BASIC (version 5.7, 1985, Data General – DG Nova)
Enterprise IS-BASIC (version 1.0, 1985, Elan/Intelligent Software – Z80)
Amiga BASIC (version 1.2, 1986, Microsoft – 68000)
Atari ST BASIC (1987, Metacomco – 68000)
GfA BASIC (version 3.51, 1988, GFA Software – 68000)
GW-BASIC (version 3.23, 1988, Microsoft – 8088)
QBasic (version 1.1, 1992, Microsoft – 8088)
It’s a little hard to see trends in a sea of bullet points, but:
Up until about 1975, BASIC systems from DEC, Hewlett-Packard and IBM did the right thing with FOR loop variables.
Small BASIC systems on the Intel 8080 appearing after 1975 introduced uncertainty in FOR loop behaviour.
Many of these iffy systems were written by Microsoft, though many other vendors copied that behaviour. (Whether they copied code too, I can’t tell).
The ANSI working group efforts to develop a standard for...