Dartmouth Time-sharing System: BASIC
According to their 1985 book Back to BASIC, Kemeny and Kurtz had eight goals in mind when designing the language.
- It should be easy to learn for the beginner.
- It should be a general-purpose language, allowing the writing of any program.
- Advanced features had to be added so that, if there was a price, it would be paid by the expert, not the novice.
- It should take full advantage of the fact that the user could interact with the computer.
- It should give error messages that were clear and friendly to the user.
- It should give fast response for small programs.
- No understanding of the hardware should be necessary.
- It should shield the user from the operating system.
Let's take a look at the language in its first implementation on DTSS in 1964.
Detail from the cover of the original BASIC manual. Source: Bitsavers.
Dartmouth BASIC
There are only 15 keywords.
LET GOTO RETURN
PRINT IF DEF
END FOR DIM
READ NEXT REM
DATA GOSUB STOP
All variables are floating point numbers, and variables names must be
a single character or a single character followed by a single digit.
You have to use the LET
keyword to assign to variables.
PRINT
can print numbers or strings enclosed in double quotes.
This early version could only write data back to the user running the
program and was unable to take input from the the user. This was
implemented two years later by adding the INPUT
keyword and OS
support. The emulator does support INPUT
, but we'll be historically
accurate by using the READ
statement to take data from a DATA
statement in the program.
GOTO
allows jumps to any line number, GOSUB
also jumps to the
given line number, but when RETURN
is reached it will transfer
execution back to the line after the GOSUB
.
Up to 26 functions, containing a single expression only like Fortran,
can be defined with DEF
.
The result of an IF
statement can only be a line number which is
jumped to if the expression is true.
Let's exercise BASIC by implementing the TPK algorithm.
TPK in BASIC
100 REM TPK ALGORITHM IN BASIC
110
120 DEF FNT(X) = SQR(ABS(X)) + 5*X^3
130
140 REM MAIN PROGRAM
150 DIM A(11)
160 LET N=11
170 REM READ NUMBERS FROM DATA
180 FOR I = 1 TO N
190 READ A(I)
200 NEXT I
210 PRINT "RESULTS ARE"
220 FOR J = 1 TO N
230 LET K = N - J + 1
240 LET R = FNT(A(K))
250 IF R > 400 THEN 280
260 PRINT R
270 GOTO 290
280 PRINT "TOO LARGE"
290 NEXT J
300 DATA 10, -1, 1, 2, 3, 4, 4.3, 4.305, 4.303, 4.302, 4.301
310 END
In line 120, we use ^
to raise X
to the power of 3.
Arrays are zero indexed, but we use 1-11 for the array defined on line 150.
The READ
on line 190 takes values in order from the DATA
on
line 300. You could substitute INPUT A(I)
here to take input from
the user.
Executing this on the emulator
- See the quick tour on how to get the emulator running.
- Download the source file from Github.
- If you are not on Windows, ensure the file has CR/LF line endings. A simple way to do this:
awk 'sub("$", "\r")' < input_file > output_file
- Store the file as
TPK
(no extension) in the same directory asDTSS.EXE
. - Start DTSS.
- Type
OLD TPK
. - Type
LIST
to confirm the source has been loaded. - Type
RUN
.
The results will look like this:
OLD TPK RUN TPK 18:55 JUN 23, 2025 RESULTS ARE 399.886 TOO LARGE TOO LARGE TOO LARGE 399.609 322 136.732 41.4142 6 -4 TOO LARGE TIME 0. SECS
Further information
The DTSS emulator zip file contains A BASIC Outline.pdf. A 1964 introduction to the system and BASIC can be found on bitsavers.
Questions, corrections, comments
I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.