This page discusses, at a high level, the history of Wang BASIC and some of its salient characteristics.
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
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. The Wang BASIC Versions page has details of the various flavors of Wang BASIC of the first generation 2200 machines.
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
READYprompt. 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
RUNa 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
GOSUBstatements 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.
The 2200VP CPU used a different, more powerful, microarchitecture than the first generation CPUs had, and so the BASIC interpreter had to be rewritten. At the same time, Wang enhanced it in a number of ways, producing what is called Wang BASIC-2.
The microstore in the first generation CPUs was implemented in a number of custom mask programmed ROMs. Changing the interpreter was possible either by using a patch ROM (limited to changing just a few instructions), or by wholesale replacement of ROM sets. Either was expensive, both in materials and in the need to have a field service call to swap the hardware. The 2200VP and later CPUs used SRAM to hold the microstore. Although there was a longer boot process in order to load the interpreter off disk, the benefit was that bug fixes and enhancements could be distributed simply by mailing out new boot disks.
Wang BASIC-2 was almost 100% upwards compatible with Wang BASIC. The biggest missing feature was explicit support for the cassette tape drive. Existing syntactic features were generalized, and some of the features not found in Dartmouth BASIC but found in other contemporary interpreters, such as the "ELSE" clause, were added, and limits on array size were raised.
The BASIC-2 page has specific syntactic enhancements, but this section contains an overview.
Thanks to former Wang engineer John Baxi, an unreleased Wang product has now seen the light of day. The first Wang PCs were not fully IBM compatible, as Wang thought doing them one better would lead to a successful product. They'd soon learn that compatibility was valued more than enhanced features.
Although the Wang PC was released with a Microsoft GW BASIC interpreter, Wang also produced a BASIC-2 interpreter. The interpreter was running on an 8086 but was significantly slower than BASIC-2 running on a 2200VP CPU. For whatever reason, they decided not to release it.
Unfortunately, the interpreter (zip file here) does not run on standard PC hardware. I'm hoping that someone who has a still-functioning "classic" Wang PC will be able to try out the interpreter. Please, let me know if it works, and whether it is stable.
Thanks to Peter Koelewijn, you can now use the Wang-2 BASIC interpreter on your modern PC. In fact, you can run any Wang PC software on your modern PC, so long as it is running a 32b OS. (You can run it in a 32b VM DOS shell if you only have a 64b version of windows; however, I've found that the interpreter doesn't run stably running windows xp under vmware player). The second hitch is that the keyboard mapping is incomplete, rendering some program features useless.
Download this zip file, unpack
the contents into some folder on your PC, then set yourself up with a DOS shell
one way or another and 'cd' your way over to where you unpacked the zip file.
There is nothing to install; just run the program. To run the BASIC-2
interpreter, you must type
wang basic2.exe. The first part
invokes the WANG.EXE compatibility layer, and the second part, BASIC2.EXE,
is the program to run.
Keep in mind that CTRL-R is like hitting the RESET button on a real machine.
How fast is it? On my 2.66 GHz recent vintage Core i5 CPU,
10 FOR I=1 TO 100000000:NEXT I runs in about six seconds.
This is 4200 times faster than a real Wang 2200. My 2200 emulator running
full out is only 21 times faster than a real Wang 2200 due to the overhead
of interpreting the original microcode.
After you are done playing around with BASIC2.EXE, you might want to check out a couple other Wang products Peter has included in the zip file. One is in the subfolder WDB, a database product, and WWP, a word processing product. It helps if you can read Dutch.
Because the (M)VP CPU had a writable control store, patches to BASIC-2 were easy to deploy, but there was nothing stopping Wang from supporting a completely different language if they wanted to.
In fact, Wang did develop an enhanced dialect of BASIC called BASIC-3, as well as a COBOL interpreter. These were announced and demonstrated on April 2, 1981 at the Hannover Fair, Germany. In addition to the new languages, the file system was enhanced to allow more sophisticated file management than was possible under BASIC-2.
To hold all the microcode for the new languages, a system would need a $2000 modification to double the size of its control store. Enhanced systems could simultaneously run BASIC-3 and COBOL programs, though a given partition could run only one at a time. Humorously, the engineers referred to this product as BASBOL (pronounced "baseball").
Wang even produced a COBOL coding form for the 2200. It was a behemoth at 14"x12" (35.5cm x 30.5cm).
BASIC-3/COBOL got as far as beta site testing before the project was canceled. Apparently Wang management felt that such a system was starting to encroach on the low end of the VS family and they wanted a clear distinction between the 2200 and the VS families.
2200 COBOL was ANSI 1974 Level 1 compatible, and was fully compatible with VS COBOL. BASIC-3 would have been at largely modeled after the version of BASIC developed for the 2200VS family of computers. Having forward compatibility would make sense to make it easier for customers to upgrade their systems as they grew.
Further insight into Wang's thinking can be obtained by reading these internal memos.
The best insight into what the languages looked like is to inspect the Wang BASIC-3 datasheet and the Wang 2200 COBOL datasheet. Another possible source of hints it that BASIC-3 would have been largely modeled after Version 3 of 2200VS BASIC.
If anybody still has any documents, disks, or even just recollections of BASIC-3 or COBOL for the MVP, please contact me!
More detailed summary information on Wang BASIC can be gleaned from the Wang BASIC Versions page, BASIC-2 page, as well as the Wang BASIC vs. MS BASIC page. To really get the full scoop, read the Wang BASIC manual or the Wang BASIC-2 manual.