Minimal BASIC

Minimal BASIC is a dialect of the BASIC programming language developed as an international standard. The effort started at ANSI in January 1974, and was joined in September by a parallel group at ECMA. The first draft was released for comments in January 1976 and the final standard, known alternately as ANSI X3.60-1978 or ECMA-55, was published in December 1977. The US Bureau of Standards introduced the NBSIR 77-1420 test suite to ensure implementations met the definition.

By this time, Microsoft BASIC was beginning to take over the market after its introduction on early microcomputers in 1975, and especially after the introduction of the 1977 "trinity" - the Apple II, Commodore PET and TRS-80, all of which would cement MS-style BASICs as the de facto standard. ISO standardization of Minimal BASIC began as ISO 6373:1984 but was abandoned in 1998. An effort to produce a more powerful dialect, Full BASIC (also known as Standard BASIC), was not released until January 1987 and had little impact on the market.

Previous developments
Dartmouth BASIC was introduced in May 1964 at Dartmouth College as a cleaned up, interactive language inspired by FORTRAN. The system brought together several concepts which were hot topics in the computer industry at the time, notably timesharing to allow multiple users to access a single machine, and direct interaction with the machine using computer terminals. General Electric, who supplied the GE-225 computer it ran on, marketed a slight variation to commercial users and saw immediate uptake. A number of other companies soon introduced similar systems of their own, selling online time by the minute. By the end of the 1960s there was a version of BASIC for almost every mainframe platform and online service.

In 1966, Hewlett-Packard (HP) introduced a new minicomputer, the HP 2100. Intended to be used in laboratories and factory settings, the company was surprised to find most were being sold for business processing. Looking to take advantage of this, in November 1968 they introduced the HP 2000, a system using two HP 2100 CPUs which implemented timesharing to support up to 32 users. The system worked in a fashion similar to the Dartmouth model, using one machine to control input/output and another to run the programs. In contrast to the Dartmouth versions which were compilers, HP Time-Shared BASIC was an interpreter.

Interpreters quickly became common on smaller machines and minicomputers. Other vendors quickly copied the HP dialect, notably Data General for their Nova series which were very successful in the early 1970s. Wang Laboratories also had some success with their dedicated BASIC machines, the Wang 2200 series. Each version had its own differences. One holdout was Digital Equipment Corporation (DEC), who had been involved with the JOSS program at the Stanford Research Institute (SRI) and introduced their FOCAL language based on it. By the early 1970s the success of BASIC forced DEC to introduce a BASIC of their own with its own set of modifications.

Standards efforts
The divergence of BASIC led to interest in producing a standard to try to bring them back together. The first meetings on such a possibility took place in January 1974 under the newly-formed ANSI working group X3J2. This led to a corresponding group being set up in September 1974 in Europe under the ECMA, TC 21. The two groups remained in close contact throughout the effort and released their respective standards at the same time. The first draft, was released by ANSI in January 1976. The final version was prepared in June 1977, and officially adopted by the ECMA on 14 December 1977.

Minimal BASIC was essentially the original 1964 Dartmouth BASIC written as a formal standard using an Extended Backus–Naur form with an associated test suite to ensure implementation complied with the definition. It clarified formerly undefined concepts like whether  and GOTO were the same thing, in this case stating that , meaning GOTO,   and even   were identical. Where differences between implementations existed, like in the handling of the FOR statements or whether or not spaces were required between keywords and values, the standard always selected the Dartmouth pattern.

It was always understood that Minimal BASIC was not really useful on its own as it lacked many common features like string manipulation. These more advanced features would be a focus of the follow-up effort, Full BASIC, which began serious work after the publication of Minimal. Full BASIC was not simply a version of Minimal with more features, instead, it was based on Dartmouth's Structured BASIC efforts and was designed to offer structured programming to support the construction of large programs. In contrast to Minimal, Standard BASIC was designed to significantly update BASIC.

Irrelevance
While the Minimal BASIC effort was taking place, the first widely available microcomputer was released, the Altair 8800. Shortly thereafter, Altair BASIC was released by Microsoft. Within the year, dozens of new micros were released and as many new versions of BASIC. By the time the Minimal standard was ratified, there were already tens of thousands of machines running some variation of the language. Which dialect any particular interpreter followed was generally based on the machines used to develop it; MS BASIC was developed on a PDP-10 and has many features from DEC's BASIC-PLUS, while Apple BASIC was written by Steve Wozniak based on an HP manual and uses HP's system of string handling.

The first draft of the Minimal standard was released for comments in January 1976. Numerous comments were used to update the draft and its final release was prepared in June 1977 and formally ratified by the ECMA on 14 December 1977. The US Bureau of Standards released the NBSIR 77-1420 test suite to allow vendors to test compliance with the standard. As there were no microcomputer vendors in the standards groups, the system mostly found use on mainframe versions, which invariably had many extensions. One of the few microcomputer versions to implement the standard was Microsoft's BASIC-80 for the Zilog Z80, better known as MBASIC, which gained compliance with the standard in its 5.0 version.

After the release of Minimal, the standards groups turned their attention to Full BASIC, but this dragged on for years. The effort proceeded so slowly that the Dartmouth participants left and released their own version of the still-emerging standard as True Basic in 1984. This was bug-ridden and confusing, leading Jerry Pournelle to deride it as "madness" and John Dvorak to dismiss it as "sad" and "doomed to failure." Plans to move Minimal BASIC to the International Organization for Standardization (ISO) were abandoned, and the ANSI group broke up leaving the original standards inactive.

Description
Minimal BASIC is closely based on early versions of Dartmouth BASIC and follows its conventions. The standard mostly clarifies certain limitations in an effort to produce a standard that can run on almost any machine. The following description assumes a basic familiarity with common BASICs, and highlights the differences in Minimal.

Program code
Like most BASIC implementations, Minimal is based on the underlying source code being edited using a line editor and thus every line of code in Minimal has to have a line number. The standard allows line numbers between 0 and 9999. In contrast to some interpreters, Minimal requires a space before every keyword, and a space or end-of-line after it.

Keywords include REM, DIM, OPTION, DEF ,LET, PRINT, INPUT, READ, DATA, RESTORE, IF...THEN, FOR...TO...STEP...NEXT, GO TO, GO SUB...RETURN, ON...GO TO and ON...GO SUB..., RANDOMIZE, STOP and END.

Programs are required to have an END as their last line. INPUT may have an optional prompt string, but that is up to the implementation, not part of the standard. RESTORE did not allow a line number, an option seen in most interpreters of the era. FOR...NEXT loops are top tested, and will not execute their body if the test fails on the first iteration.

Variable names can consist of a single letter, or a letter and a single digit. Two-letter variable names are not allowed. Numbers are limited to the range 1E-38 to 1E38. String variables can have a maximum of 18 characters. Arrays can be one or two dimensional using DIM, but only numeric arrays are supported. All variables are normally allocated space in an associated one-dimensional array without using DIM, they are given space for 11 items, indexes 0 to 10. The lower bound for arrays is typically 0, but using OPTION BASE 1 can change the index to 1.

There are 11 defined functions; ABS, ATN, COS, EXP, INT, LOG, RND, SGN, SIN, SQR and TAN. Operators include =, <=, >=, <>. Strings could only be compared for equals or not-equals, larger and smaller comparisons were not supported. Note that the logical operators, AND, OR and NOT, are not supplied.

User-defined functions using DEF FN were supported, but only for numerics. No built-in or user functions for strings were available.

Example
This code implements the Sieve of Eratosthenes:

Currently Maintained Open Source Implementations

 * Jorge's bas55 ECMA-55 Minimal BASIC Interpreter
 * John's ECMA-55 Minimal BASIC Compiler