image of READY prompt

Wang2200.org – BASIC

This page discusses, at a high level, the history of Wang BASIC and some of its salient characteristics.

Prehistory (link)

BASIC was developed at Dartmouth University by John Kemeney and Thomas Kurtz in 1964. It was intended to be an educational language, simple to learn the basic concepts of programming for college students.

BASIC was somewhat modeled on FORTRAN, and like FORTRAN, the early versions of BASIC were focused on computations. Handling textual data was not well supported. For instance, in 1964 BASIC supported an assortment of matrix operation primitives via the MAT statement, yet the only textual representation was string literals for PRINT statements.

Wang's first attempt at BASIC came not with the 2200, but the Wang 3300. The 3300 was a general-purpose processor, taking aim at the PDP-8 class of customer. Timesharing interpreted BASIC and FORTRAN were developed for the 3300, but, for various reasons, the product was unsuccessful.

The 3300 BASIC interpreter went through a few revisions. The first version was very much like Dartmouth BASIC, in that it supported all the usual BASIC constructs and MAT statements, but had only string literals. An extended BASIC was eventually developed, which added support for string variables, although the strings were allocated 18 bytes and thus no string variable could be longer than that.

Although the 2200 CPU microarchitecture was very different from the 3300 CPU, the structure of the 2200 BASIC interpreter, called Wang BASIC, borrowed heavily from the 3300 experience, to the point that the two even shared some design flaws! Nevertheless, the 2200 Wang BASIC evolved to be more powerful, both numerically and in its ability to process text data.

Significant Characteristics of Wang BASIC (link)

Here are a few important features about Wang BASIC:

  • Wang BASIC was stored in ROM on the 2200. This had a couple of implications. One of the criticisms of the 3300 was the fact that it took 40 minutes to load the BASIC interpreter from paper tape. With BASIC in ROM, the 2200 was ready to run programs before the CRT got warm enough to display the READY prompt. Also, it meant that it was very expensive to fix bugs, as it required a field upgrade to the ROMs.

  • Wang BASIC was interpreted. Although it hurt performance somewhat as compared to a compiled BASIC, it made the implementation much simpler and less costly. Interpreted BASIC is more interactive and immediate. Also, because the CPU didn't have floating point accelerator hardware, much of the time was spent in the floating point routines. While a compiler speeds up the interpretation and symbol table look-ups, it does nothing to help time spent in library routines, such that a compiled version would only be a small factor faster than an interpreted one.

  • Wang BASIC followed Dartmouth BASIC conventions pretty closely, which was pretty limiting. Variable names were either a single letter or a letter and a number. There was almost no concept of scoping; in essence every variable was a global. There was one exception to this: the DEFFNx() statement did localize its single argument variable.

  • Wang BASIC had two fundamental data types: double precision floating point numbers (8 bytes holding 13 bcd mantissa digits, two bcd exponent digits, and one nibble encoding the signs of the mantissa and exponent), and fixed size character strings, from 1 to 64 characters. Wang BASIC also supported 1-D and 2-D arrays of both of these types. That all Wang BASIC numbers were double precision was reflective of Wang's calculator heritage.

  • Program syntax was checked upon entry and errors were reported immediately. It wasn't possible to RUN a program that had syntax errors. Compare this to Microsoft BASIC, where a line containing a syntax error wasn't noted until that line was actually executed.

  • Assuming all lines had legal syntax, when a program was requested to RUN, the interpreter cleared its symbol table, then scanned all program lines. This caused a slight delay before the program begins running, but it served two important purposes. First, the interpreter noted if there were any GOTO or GOSUB statements which attempted to branch to a non-existent line. If there were any problems of that sort, it was reported and the program halted. Microsoft BASIC of that era would blindly execute the program and barf only when a bad branch was attempted.

  • Secondly, this resolution phase noted all variables and all array declarations and would allocate space for them in the symbol table before any code was executed. Because of this static data allocation, if there wasn't enough memory to run the program, it would not even run, vs. dieing at some indeterminate point at run time. Another benefit of static data allocation was that there was no need for garbage collection.

  • The static allocation of data had disadvantages too. The length of string variables had to be declared up front, thus the worst case scenario had to be anticipated. This was especially bad in the case of string arrays, since even if only a single string in the array had to be 64 characters wide while the rest were only 10, all strings would occupy 64 bytes.

Learn More (link)

More detailed summary information on Wang BASIC can be gleaned from the Wang BASIC Versions page, as well as the Wang BASIC vs. MS BASIC page. To really get the full scoop, read the manual.

With the introduction of the 2200VP machine, Wang BASIC was rewritten as BASIC-2, and many of the shortcomings of were either eliminated or at least reduced.