Why Use BASIC?
We convinced the makers of the early microcomputers that they needed BASIC in their machines to let people use them. Otherwise, you could turn on the machine, but you couldn't do much with it. And until disk operating systems came along in about 1979, BASIC was the only way most people could use a personal computer. Our BASIC caught on because we encouraged people to write books about BASIC programming that contained lots of source code listings. We also promoted the idea of people writing programs in our BASIC and then selling or giving away those programs.
Other people were writing BASICs at that time: Li Chen Wang (Tiny BASIC), Steve Leininger (Radio Shack Level I BASIC), Steve Wozniak (Apple Integer BASIC), and Gordon Eubanks (BASICe and CBASIC). But Microsoft BASIC eventually appeared in the ROMs of over 50 types of machines and became a de facto standard.
That early BASIC was primitive compared to today's language. It forced you to use only two-letter variable names and required line numbers (see Listing 2). But it proved to be an acceptable way to create useful programs for computers.
10 REM 1977 8K BAS 15 PRINT "ENTER NUMBER FOR MULTIPLICATIO TABLE" 20 INPUT NUMBER 25 INPUT "ENTER NUMBER OF LINES"; LINES 26 IF LINES <1 GOTO 120> 30 PRINT "MULTIPLICATION TABLE FOR", NUMBER 40 FOR I = 1 TO LINES 50 PRINT I, NUMBER * I 60 NEXT I 70 PRINT "-------------" 80 PRINT "DO YOU WANT ANOTHER Y/N"; 90 INPUT C$ 100 IF C$ = "Y" GOTO 15 115 REM 120 REM ERROR HANDLING 130 PRINT "WRONG NUMBER OF LINES" 140 END
It gave you instant feedback as you wrote a program, and its string-handling features let people write fairly sophisticated text-oriented applications. We invented new BASIC verbs like PEEK and POKE, and INP and OUT, to let people get at the resources of the machine: We devised a way to let programmers call machine language routines from BASIC so they could make critical parts of their programs faster.
Interpreters can be extended quite easily, so we frequently added new features to BASIC. We developed the music and graphics-string macro languages that used the verbs PLAY and DRAW. Many features that ended up in GWBASIC (short for "Gee Whiz") came from our experience writing interpreters for Japanese machines.
BASIC hit a plateau when GWBASIC was put into the IBM PC ROM. Without IBM's updating the ROM, it was hard to popularize BASIC extensions beyond the interpreter. This BASIC became extremely popular, of course, and even today I'm amazed at what a high percentage of PC users have experimented with that BASIC because it is so simple to learn and use.
When BASIC faltered on the plateau of being an IBM PC-compatible standard, we created QuickBASIC. Other companies were extending BASIC, too -- for example, BASIC's inventors, Kemeny and Kurtz, with True BASIC.
Not So Basic
When I show programmers the BASIC I use today, they say something like, "That looks a lot like Pascal." People who think of BASIC as the IBM PC's BASICA are surprised that it doesn't have to be a line-oriented language with little structure. BASIC has become very modern since 1983 (see Listing 3).
INPUT "File to be searched"' F$ INPUT "Pattern to search for";P$ OPEN F$ FOR INPUT A WHILE NOT EOF LINE INPUT #1, TEST$ CALL LINESEARCH(TEST$,P$) WEND SUB LINESEARCH(TEST STATIC NUM NUM = NUM = 1 X = INSTR(TEST$ IF X = O THEN EXIT SUB ELSEIF X > O THJ PRINT "Line J END IF END SUB
In the mid-1980s, BASIC improved on three fronts: as a language, with the addition of long variable and label names, record structures, and better block-structuring tools; as an environment, with a built-in editor, debugger, and compile-run facility; and as a compiled language, with faster response in the classic compile/debug/edit/compile cycle while generating fast, high-quality code. BASIC also gained the ability to run recursive routines, to handle sophisticated structures such as B-trees, and to deal better with graphics.
About this time, BASIC became more structured, with the addition of DO WHILE, WHILE. ..WEND, DO UNTIL, LOOP WHILE, and LOOP UNTIL loops, and SELECT CASE constructs. BASIC today has facilities that permit creating data structures as rich as those ofC or Pascal. BASIC also shed the shackles of 64K-byte limits on program size; today's BASIC programs are limited only by memory, and even individual arrays can be up to the limits of memory in size.
You can also use long (32-bit) integers in your programs. Record structures added the capability to let you define your own data structures, combining many different individual data types, such as strings and numbers.
The environment for BASIC programming has changed, too. In QuickBASIC 4.0 and 4.5, for instance, a built-in full-screen editor with automatic syntax editing, a built-in debugger, and those "foreign" language routines from within your program-creation process as fast and easy as possible. Borland also integrated a full-screen editor in Turbo Basic.
Another important change in the modern BASICs was a move from interpreters back to compilers: Indeed Dartmouth BASIC has remained a compiled language since its inception. BASIC compilers for microcomputers appeared soon after disk operating systems became available, and were made possible, in part, by the availability of up to 64K bytes of memory.
These compilers included Microsoft products and Digital Research's CBASIC-86 compiler. Later, Better BASIC, QuickBASIC, True BASIC, ZBasic, and Turbo Basic were developed. But the major move to compilers needed to be made without sacrificing the instant feedback and quick detection of errors, features that made the BASIC interpreter so successful.
Advancements in compiler technology enabled the development of a BASIC compiler that gave the appearance of an interpreter, thus offering the best of both worlds. Single-pass compilers that could compile first hundreds--and then thousand of lines of code in just a few seconds gave BASIC the appearance of an interpreter but let programs execute faster.
Later, we invented an in-memory scheme combining the features of an interpreter and a compiler. It uses a special intermediate threaded pseudocode that, when combined with an environment like the QuickBASIC editor, lets you write, debug, and change the code just like in an interpreter. When you are ready, you can compile the finished product to get maximum speed and compact size in an executable file.
Compiling BASIC also made it easier to call routines written in other languages from within BASIC. Because the compiler generates standard intermediate .OBJ files, you can link C or FORTRAN .OBJ files with your BASIC .OBJ files and callthose "foreign" language routines from within your BASIC program.
With these improvements in compiler technology, BASIC's longtime reputation as a slowly executing language fell by wayside. Today, many popular commercial applications are written in BASIC. For example, a program called AccoustaCADD, a radio station playlist manager called Music Scan, and even a program for molecular biologists called DNA Inspector. Modern compiled BASIC as fast as programs compiled in Pascal or C.
I'm still a big fan of BASIC. It handles many of the overhead tasks that other languages force you to deal with, thereby unleashing your programming creativity. Programmers to write code to solve any problem they choose; I wager that I can write the same program faster using QuickBASIC. In fact, there is a joke around Microsoft that says when an application is falling behind schedule, "Just give it to Bill and he'll write it in BASIC over the weekend."
Still, as powerful as BASIC is today, there are way to make it even better.