Channels ▼

Open Source

BASIC At 25 Years of Age

Since the first program ran on an English-built computer in 1948, computing has evolved by several orders of magnitude. In just 15 years, personal computers have grown from 8-bit, 4K-byte toys to powerfu1 32-bit, 16-megabyte tools for science and industry.

Amid all this growth in hardware, the BASIC language has quietly turned 25 years old, and the BASIC interpreter that opened up the microcomputer to millions of people has entered its fifteenth year.

BASIC didn't become the best-known and most accessible computer language simply because it comes free with every machine. BASIC's strengths-the simplicity of using iin interpreter, its powerful string handling, the richness of the language, its English-like keywords and syntax, and the freedom it gives programmers to experiment-make it the ideal way for computer novices to explore the intricacies of their computers.

During this milestone year for BASIC, you can see how it may evolve by looking at the technology of operating systems like OS/2 and the promise of object-oriented programming.

BASIC was born out of a need to give nontechnical people a simple way to interact with a computer. In 1962, a math professor at Dartmouth College, Thomas Kurtz, proposed to the department chairman, John Kemeny, the radical idea that all Dartmouth students should learn about computers during their four-year stay. But the batch-oriented computers of the day made that prospect impossible, since it often took days to find out ifa simple program would compile properly. Even then, the program could only calculate a result and return an answer; the person who wrote the program never actually saw it run.

Kemeny and Kurtz, expanding on research going on at MIT and Bell Labs, built a time-sharing operating system for a new computer that Dartmouth was about to receive. In the process, they decided that giving students a way to share the computer's hardware was of little use without a simple language for talking with the machine. FORTRAN and ALGOL didn't fill the bill for ease of use, so they created the Beginner's All-purpose Symbolic Instruction Code as a simplified blend of the best of FORTRAN and ALGOL.

On May 1, 1964, Partmouth students, greeted by the now famous READY > prompt on their teletype terminals, could write simple programs and send them off to be compiled and run. Listing 1 shows a simple program (a multiplication table.) written in that first BASIC. Kemeny and Kurtz recount the birth of BASIC in their book Back to BASIC (Addison-Wesley, 1985).

10 REM 1964 BASIC 
20 LET N = 355/113
40 FOR I= 1 TO 10 
50 PRINT I, N * I
60 NEXT I 
70 PRINT "-------------"
80 END

Listing 1: The 1964 BASIC had no input statement. Instead you had to assign data to a variable with the LET or READ DATA statements.

...And Then There Were Micros

The first microcomputers, sporting very small memories, came on the scene in 1975 from companies like MITS and Southwest Technical Products. These machines understood only machine language. Paul Allen and I sensed an opportunity and wrote a version of BASIC to run in those small memory spaces. Our first BASIC for the MITS Altair allowed a user to run programs on a 4K-byte machine. Memory was so precious that we even replaced the READY > prompt with OK > to save a few bytes. We built this BASIC as an interpreter.

Memory constraints partly guided our decision to implement BASIC as an interpreter. But another factor was our fascination with interpreters, and the immediacy and ease of use they give to the programming art. An interpreter lets a programmer tell the computer to perform ajob, and then the computer gives immediate feedback and results, including the reporting of errors. This immediacy comes from the interpreter's being built as part of the language, not as a separate program like a compiler. First-time users would find working with a compiler difficult.

Prawing on experience I had obtained writing a BASIC interpreter for a PDP-8 while in high school, Paul and I made our original microcomputer BASIC a single-representation interpreter. This means that rather than storing the exact source code in text form, we translated it into a more compact form because of the memory constraints we faced.

We did tricks to let the programmer see his or her program speed. Using the lower values of a byte and the 128 ASCII values to tokenize BASIC keywords was an innovation in that interpreter. We also coined the short commands TRON and TROFF to turn on and off BASIC's earliest a trace facility. Fitting the language's reserved words, error messages, and floating-point library to run programs in a 4K-byte machine required a lot of tricks--it's still my favorite piece of code because it is so refined.

We chose to write a BASIC interpreter for several reasons. BASIC was simple enough that we thought we could squeeze it, plus user programs, into 4K bytes. We also liked being able to write a meaningful one-line program in BASIC; with other languages, you had so many variable and environment definitions to worry about, you had to write several lines of code just to print "hello" on the screen. And we liked BASIC's powerful variable-length string-handling functions.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.