BASIC Programming Language
Total Page:16
File Type:pdf, Size:1020Kb
BASIC Programming Language Thomas E. Kurtz Dartmouth College I. Brief Description II. Early History of BASIC III. Growth of BASIC IV. Standardization and its Failure V. The Microcomputer Revolution VI. Present and Future GLOSSARY the rules of the language and with the purpose of car- rying out a particular computing task. BASIC Name of any of a large number of simple Run Actual carrying out of the instructions of the pro- programming languages that are similar and ulti- gram by the computer. mately derived from the original Dartmouth BASIC of Statement Instruction to the computer. In BASIC, state- 1964. ments are virtually synonymous with lines and usually Keyword Word in a computer language that has a special begin with a keyword. meaning. (Keywords in BASIC include, for instance, Subroutine Portion of a program, usually set off from the LET, PRINT, FOR, NEXT, TO, and STEP.) rest of the program, that carries out some specific task. Language In computing, a programming language. Pro- Subroutines are usually invoked by special instructions, gramming languages like human languages, consist of such as GOSUB and RETURN in original BASIC, or words and symbols together with grammatical rules CALL in modern versions. that govern how they can be put together. Variable Word in a program, usually different from a Line Same as a line of text, beginning with a line number keyword, that stands for a quantity, just as in ordinary in original BASIC. algebra. Line number Integer (whole number) that begins each line of a BASIC program and serves as a kind of “serial number” for that line. Line numbers also serve BASIC (Beginner’s All-Purpose Simplified Instruction as “targets” for GOTO statements. Code) began as an interactive computer programming lan- List A list of a program is a “printout” on the screen of guage especially easy to learn. Invented in 1964, it now a computer or on a hard-copy printer, of the text of the exists in many widely different versions. Students learn- program (i.e., its lines). ing programming for the first time may know BASIC as Program Collection of statements, formed according to the simple language found on most personal computers. 23 24 BASIC Programming Language Others know BASIC as a development language on 100 INPUT X, Y personal computers and workstations. This article ex- 110LETZ=X+Y plores the history and development of BASIC, at least 120 PRINT Z some of the versions of BASIC, and explains why this 125 GOTO 100 language has become so diverse and yet so popular. 130 END I. BRIEF DESCRIPTION This time, the result might look like this: Nearly everyone who has heard about computers has heard RUN about the BASIC language. Many of these people can read ?3,4 and write simple programs in BASIC. Note that, in 1964, 7 long before personal computers or display terminals, one ? 1.23, 4.56 entered a program by typing (as now) and the computer 5.79 responded by typing back onto yellow paper (rather than ? − 17.5, 5.3 displaying results on a screen): − 12.2 ? 100LETX=3 110LETY=4 The user continued in this fashion until all additional 120LETZ=X+Y problems had been “solved.” The user then stopped the 130 PRINT Z program by some method that varied from machine to 140 END machine. The above examples will be trivial to anyone who knows Almost anyone who has taken high school algebra will BASIC but should be understandable even to someone understand what this program does and understand it well who has not used BASIC. It is not the purpose of this ar- enough to make changes in it. (When run, it prints the ticle, however, to teach the language through such sim- number 7.) ple examples. The purpose is rather to use these and BASIC was invented for an interactive environment later examples to illustrate an important point: BASIC (time-sharing or personal computers). The user could start is not just a single computer language; it is actually a and stop the program at will and could interact with the collection of many languages or dialects, perhaps hun- running program. For instance, the INPUT statement in dreds that have evolved since the mid-1960s. As a re- the following program allowed the user to enter the num- sult, versions that run on different brands of computers bers to be added after typing RUN (remember, all com- are different. It has even been the case that different mod- mands had to be typed; there were no mouses or menus): els of the same brand have sported different versions of BASIC. 100 INPUT X, Y For example, some versions of BASIC allowed the user 110LETZ=X+Y to omit the word LET, to omit the END statement, or to 120 PRINT Z employ either uppercase letters or lowercase letters inter- 130 END changeably. For example, the first program above might be allowed to appear on some computers as: After the user typed RUN, the program stopped (temporar- ily), printed a question mark (?), and waited for the user 100x=3 to respond. The user then typed two numbers, separated 110y=4 by a comma, and followed by hitting the RETURN or 120z=x+y ENTER key. The program then commenced, calculated Z 130 print z (as the sum of the two numbers), and printed the answer. The result might look like this on the yellow paper, or on One more important way in which versions of BASIC the screen of an early microcomputer: developed is that some allow “structured programming” (discussed later.) Recall an earlier example: RUN ? 3.4 100 INPUT X, Y 7 110LETZ=X+Y 120 PRINT Z A user who wished to make several additions could 125 GOTO 100 arrange for the program to continue indefinitely, as in: 130 END BASIC Programming Language 25 One of the tenets of structured programming is that undergraduate students.) The new language, BASIC, easy GOTO statements (as in line 125 above), used carelessly, to learn and easy to use, was an essential part of this effort. are the cause of many programming errors. All modern BASIC was thus developed originally for a large multiple- versions of BASIC allow the user to rewrite the above user, time-shared system and not for personal computers, program without using GOTO statements as: which did not appear widely until the early 1980s. It has been asked why BASIC was invented. Couldn’tan 100 DO existing language have been used for the purpose? The an- 110 INPUT x, y swer to the second question is no, which also answers the 120 LETz=x+y first question. Other computer languages did exist in 1963, 130 PRINT z although there were not nearly as many as there are today. 125 LOOP The principal ones were FORTRAN and Algol; most of 130 END the others are long since forgotten. Some of the common languages used today—C, C++, and Java—had not even The collection of lines starting with 100 DO and end- been conceived. FORTRAN and Algol were each consid- ing with 125 LOOP is known as a loop. The interior lines ered briefly. These languages were designed for produc- of the loop are carried out repeatedly, as in the example tion use on big machines or for scientific research, using by using a GOTO statement. Notice, in addition, that the punched cards. But neither was suitable for use by begin- program is written in mixed case (using both upper- and ners, neither was particularly well suited for a time-shared lowercase letters), and the interior lines of the loop are in- environment, and neither permitted speedy handling of dented. All modern versions of BASIC allow these stylistic short programs. Kemeny and Kurtz had experimented with improvements. other simple computer languages as early as 1956, but Eliminating the GOTO statement (line 125) removes the with only modest success. So, in 1963, when they began need to reference line numbers in the program. The line building a time-shared system for students, they quickly numbers themselves, no longer serving a useful purpose, realized that a new language had to be invented—BASIC. can now be eliminated to get: DO A. Design Goals INPUT x, y The new language had to satisfy these properties: LETz=x+y PRINT z 1. It had to be easy to learn for all students. LOOP 2. It had to work well in a multiple-user, time-sharing END system. 3. It had to allow students to get answers quickly, We could not have removed the line numbers from the usually within 5 or 10 sec. version that used a GOTO statement “GOTO 100” be- cause there would no longer be a line numbered 100 in In the years since BASIC was invented the importance of the program. Some earlier versions of BASIC allowed re- time sharing has been overshadowed by the invention of moving some lines except for those used as GOTO targets, personal computers: Who needs to time-share a big ex- in which case the line numbers became statement labels, pensive computer when one can have a big (in power) a concept not present in the original BASIC. but inexpensive computer on one’s desk top? For a long time, no such dramatic improvement has been made on the programming side. Thus, while the impact of time II. EARLY HISTORY OF BASIC sharing has been largely forgotten, the importance of BASIC has increased. The ideals that forced the inven- BASIC was invented at Dartmouth College in 1963–1964 tion of BASIC—simplicity and ease of use—lead many by John G.