Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36
 

Exercise 37: Little BASIC

You are now going to take a trip back in time to my childhood and implement a BASIC interpreter. No, I don't mean BASIC as in "a really simple basic bland interpreter." I mean the programming language BASIC. It was one of the very first programming languages, originally created at Dartmouth by John Kemeny, and Thomas Kurtz. This version of basic is called Dartmouth BASIC, and the code looked something like this from the Dartmouth BASIC Wikipedia page:

5 LET S = 0
10 MAT INPUT V
20 LET N = NUM
30 IF N = 0 THEN 99
40 FOR I = 1 TO N
45 LET S = S + V(I)
50 NEXT I
60 PRINT S/N
70 GO TO 5
99 END

Those numbers to the left are actually manually entered line numbers. You told BASIC a number for each line, and then you could loop by simply telling it to "GO TO" that line. This later became GOTO in other versions of BASIC and became a kind of symbol of that era of computing.

Later versions of BASIC are documented on the main BASIC Wikipedia page, which shows a long evolution of the language into more and more--ehem--modern forms. After a while it picked up structure like C and Algol, then it got object-oriented, and today you can find fairly advanced versions of BASIC. Check out Gambas BASIC at http://gambas.sourceforge.net/en/main.html if you want to see a modern free BASIC.

Previous Lesson Back to Module

Register for Learn More Python the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.