DEC BASIC-PLUS
The late 60s and early 70s saw a siginificant divergence among BASIC dialects. Dartmouth BASIC Fourth Edition became a defacto standard of sorts.
It became clear in the early 1970s that BASIC was a hugely important language. Dartmouth’s goal of bringing computing to the masses was paying off. As with any commercial offering, competitors strive to show how their products are better. In the 1990s Microsoft coined the term Embrace and Extend, but this approach took off with a vengeance in the late 1960s. In a previous post, I mentioned how DEC and HP had dominated the 1970s. Each company had embraced Dartmouth BASIC Fourth Edition and extended its capabilities for file and string Handling. Dartmouth itself also extended the language for files and strings but was not closely aligned with the minicomputer manufacturers. (When I mention Microsoft BASIC, I mean at least GW-BASIC.)
As a child of the 1970s, my exposure to computers was through the BASIC-PLUS language on a DEC PDP-11 RSTS-11 system (Resource Sharing Time-Sharing System). I was so enthralled with programming that I bought every book I could find on programming. I quickly discovered that there were dozens and dozens of programming languages, and, in my opinion, the only language suitable for files and strings was BASIC-PLUS. I read about Dartmouth Fourth Edition and disliked its CHANGE statement for managing strings, and could find little to no documentation on files.
In the summer of 1974, I discovered that Dartmouth had made significant improvements in BASIC Fifth Edition. (I purchased a book from the Skidmore College Bookstore the week Nixon resigned. I was far more into my new book than Nixon.) They had string handling and file handling on par with BASIC-PLUS. I was convinced Dartmouth had stolen the ideas from BASIC-PLUS and made gratuitous name changes to the functions. Where BASIC-PLUS had MID$, Dartmouth had SEG$.
In doing the due diligence for this article I discovered an earlier BASIC called Super BASIC, developed by Tymshare, that provided the LEFT$, RIGHT$, and MID$ functions. Tymshare was a time-sharing service for businesses and introduced their language in 1968. So Microsoft had copied Super BASIC by way of BASIC-PLUS. I read a manual this morning on Super BASIC, which is a very large language, and only small parts of it were picked up by other BASICs. It made a mark on BASIC-PLUS and Microsoft BASIC as I’ll discuss below.
I also found an interesting quote from David Ahl on the page Basic History of BASIC - Kurtz, Ahl, Lutz, Wozniak. David Ahl was the author of the famous Basic Computer Games book. Ahl’s programs are here, Vintage BASIC Computer Games and his quote about RSTS-11 BASIC (a.k.a BASIC-PLUS) and its impact on MS BASIC reads as follows:
Altair BASIC
As the first product from the then-named Micro-Soft, this is the language that launched a multi-billion dollar empire. According to David Ahl it was largely based on RSTS-11 BASIC: “I was pleased with this as I was very familiar with it and really liked that version of BASIC. Also, I had a folder of programs in RSTS-11 BASIC which I could roll out in Creative Computing magazine and which later served as the start of the next book, More Basic Computer Games. One of my projects, along with Steve North, was to convert all of the programs in Basic Computer Games to Bill Gates’ Altair BASIC. We put a crash effort into it and the new books rolled off the presses in October 1978. Over the next few years the book was translated into five foreign languages and a mass-market version was produced by Workman Publishing.”
BASIC-PLUS is a language that almost didn’t happen. DEC’s engineers were overwhelmed with building the Operating System (RSTS-11) and had little to no time to build a language. DEC contracted the work out to a small company EGH (founded by MIT AI Lab people) to design and build a new programming language. EGH is still in business today and primarily focuses on the Telecom Industry. Before EGH’s involvement, DEC had an underwhelming bushel basket of BASICs. The PDP-8 family of BASICs, the PDP-10 BASIC, and even early BASICs for the PDP-11 had little support for strings.
As I mentioned in a previous post, strings and files, were my benchmark on the quality of a language. DEC continued to enhance BASIC-PLUS in the form of BASIC-PLUS-2 and VAX BASIC in the late 70s. The AWK programming language in Unix (1978) was the first language to provide everything BASIC-PLUS had and a million more things, think regexes! In the late 80s and today, PERL and PYTHON provide strong capabilities for strings and files.
The BASIC-PLUS Language
Enough talking about the history, here are the extensions to the BASIC language that comprise BASIC-PLUS:
More than one statement could be put on a line, using a colon separator.
IF-THEN could have a colon-separated list of commands following THEN.
An optional ELSE following a single THEN statement:
10 IF A=B THEN PRINT "HI": C=0 ! No ELSE allowed here (unlike MS-BASIC)
20 IF A=B THEN Q=D ELSE PRINT "HI": goto 50 ! ELSE allowed here. Single stmt Q=D
String functions, LEFT$, RIGHT$, MID$, INSTR, etc.
Virtual arrays (see my previous post). BASIC-PLUS Virtual Arrays
Fine-grained control over how to manage file access. This was largely copied from Super BASIC:
OPEN F$ AS FILE #1 ! READ-WRITE access. Create the file unless it alread exists
OPEN F$ FOR OUTPUT AS FILE #2 ! Create and truncate a file, prepare for write.
OPEN F$ FOR INPUT AS FILE #3 ! Open a file for sequential reading.
Sequential read and write with INPUT # and PRINT #
Control Z as a sequential file terminator (yup, that came to MS-DOS via CP/M and DEC. Many DEC OSs use Control Z).
Statement Modifiers: These are from Super BASIC and JOSS. They are not in MS-BASIC. Some of these appear in PERL.
10 Q = D UNLESS A = B ! T
20 S= 0: S=S+A(I) FOR I = 1 TO 10
30 B=B+1 WHILE A(B) = 0
40 J=K IF G=3
Matrix Math functions that implement Matrix operations of Linear Algebra.
MAT A = B + C
MAT A = C * D
Random access file I/O via the FIELD statement, LSET, RSET, GET#, PUT#. A whole bunch of functions that do hard type casting. For example, MKI$(5%) converts a 16-bit integer into a 2-byte string. The CVI operation is the reverse of MKI$(). I’d like to note that I am using the MS terminology. BASIC-PLUS called these : CVT$%() for MKI$(), and CVT%$() for CVI$()
Use of the percent sign for integers (e.g. I%). The use of percent was encouraged for integer constants, unlike MS-BASIC (e.g. FOR I% = 1% to 10%)
RSTS uses BASIC-PLUS as a systems programming language. Using Unix/Linux terminology all user-land code is written in BASIC-PLUS. As an example, the SYSTAT and LOGIN programs are written in BASIC-PLUS (this was changed in the early 80s and was converted to assembly language, I view this as a step backward).
The use of PEEK and POKE are often attributed to BASIC-PLUS, but this is not at all like the home machines built in the 80s. RSTS PEEK and POKE were for OS-privileged user-land components. PEEK fetched data from the address space used by the OS, not the address space of the BASIC-PLUS program. POKE was rarely used and was a subfunction of another privileged function named SYS(a$) and had no POKE syntax.
BASIC-PLUS Runtime, Debug, and Simulated Interpreter
BASIC-PLUS uses an incremental compiler and Virtual Machine that uses a Reverse Polish Notation called PPCODE. RSTS creates the illusion that everything is interpreted, when in reality it is compile and go. As a user types in their program, each line is compiled into PPCODE. If there is an error the user is immediately notified.
The only source code in memory is the one line the user is typing. The source code is stored in a temporary disk file after each carriage return. This is an ever-increasing file. When changes are made, the text is written to the end of the temp file, and a pointer is put in the PPCODE. When a LIST or SAVE command is given, BASIC-PLUS will create a new file with only the retained statements and in the proper order.
Unlike purely compiled languages, BASIC-PLUS supports an immediate mode. This allows the user to issue BASIC-PLUS commands that will be executed immediately. Immediate mode commands are also compiled into PPCODE. Immediate mode is very valuable for debugging. A STOP statement can be put in the code to designate a break-point. At the STOP and Ready prompt the user can PRINT variables, change variables, and anything else provided by the language. A CONT command is to resume execution of the program.
Next Time
My next post will be about HP Time-Shared BASIC and how it compares to BASIC-PLUS.
The BASIC-Plus string handling is very much like that in PL/I and I suspect that is where it came from. EG&H probably knew (about) PL/I, perhaps via Multics at MIT. Clark Baker said:
>The compiler and run time system were written by a consulting firm called EG&H. The letters were the last names of the founders. Tom Evans (went to MIT, worked in AI and wrote the Evan's geometric analogy program), Tom Griffiths (went to MIT), and Tim Hart (wrote the first garbage collector for LISP and one of the authors of the Lisp 1.5 manual (a classic from the MIT Press)).
<http://www.project-delta.net/clarkhistory.html>
I agree that the BASIC-Plus string handling functions were wonderful to work with.
By the way, there were also CVTF$ and CVT$F functions for floating point. The CVT functions simply copied the bytes of the binary int or float value into or out of a string of the same length. Their main use was with Record I/O (FIELD, LSET, RSET, GET, and PUT). Later there was also an unrelated CVT$$ function which took an integer bitmask specifying what to do to the string (whitespace removal or compaction, case conversion, etc.) Multiple things could be done at once.
I think the main use of PEEK on RSTS was, as you know, to access the operating system's tables of information about jobs running on the system. I honestly can't remember a useful application of the SYS$ function to POKE memory.
A bit of cleanup. Finally got off my a$$ and did github juju to create release info for the liner and avl repositories (as well as the basic-plus repo). This should work thusly: when you run make in the basic-plus directories, 'go build' will download (if needed) the proper release avl and liner code.