Minimal BASIC is a dialect of theBASIC programming language developed as aninternational standard. The effort started atANSI in January 1974, and was joined in September by a parallel group atECMA. The first draft was released for comments in January 1976 and the final standard, known alternately asANSI X3.60-1978 orECMA-55, was published in December 1977. TheUS Bureau of Standards introduced the NBSIR 77-1420test suite to ensure implementations met the definition.
By this time,Microsoft BASIC was beginning to take over the market after its introduction on earlymicrocomputers in 1975, and especially after the introduction of the 1977 "trinity" - theApple II,Commodore PET andTRS-80, all of which would cement MS-style BASICs as thede facto standard.ISO standardization of Minimal BASIC began asISO 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.
Dartmouth BASIC was introduced in May 1964 atDartmouth College as a cleaned up, interactive language inspired byFORTRAN.[1] The system brought together several concepts which were hot topics in the computer industry at the time, notablytimesharing to allow multiple users to access a single machine, and direct interaction with the machine usingcomputer terminals.General Electric, who supplied theGE-225 computer it ran on, marketed a slight variation to commercial users and saw immediate uptake.[2] 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 everymainframe platform andonline service.[3][4]
In 1966,Hewlett-Packard (HP) introduced a newminicomputer, theHP 2100. Intended to be used in laboratories and factory settings, the company was surprised to find most were being sold for business processing.[5] 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 controlinput/output and another to run the programs. In contrast to the Dartmouth versions which werecompilers,HP Time-Shared BASIC was aninterpreter.[6]
Interpreters quickly became common on smaller machines and minicomputers. Other vendors quickly copied the HP dialect, notablyData General for theirNova series which were very successful in the early 1970s.Wang Laboratories also had some success with their dedicated BASIC machines, theWang 2200 series. Each version had its own differences. One holdout wasDigital Equipment Corporation (DEC), who had been involved with theJOSS program at theStanford Research Institute (SRI) and introduced theirFOCAL 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.[7]
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 ANSIworking 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.[8]
X3J2's first few years were spent (in hindsight, some might say 'wasted') on standardizing what amounts to the original 1964 Dartmouth Basic... Minimal Basic was more a toy than an actual language.
Minimal BASIC was essentially the original 1964 Dartmouth BASIC written as a formal standard using anExtended Backus–Naur form with an associatedtest suite to ensure implementation complied with the definition. It clarified formerly undefined concepts like whetherGO TO andGOTO were the same thing, in this case stating thatgoto statement = GO space* TO line number, meaningGOTO,GO TO and evenGO TO were identical.[10] Where differences between implementations existed, like in the handling of theFOR statements or whether or not spaces were required between keywords and values, the standard always selected the Dartmouth pattern.[9]
It was always understood that Minimal BASIC was not really useful on its own as it lacked many common features likestring 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 offerstructured programming to support the construction of large programs. In contrast to Minimal, Standard BASIC was designed to significantly update BASIC.[11]
While the Minimal BASIC effort was taking place, the first widely availablemicrocomputer was released, theAltair 8800. Shortly thereafter,Altair BASIC was released byMicrosoft. 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 aPDP-10[12] and has many features from DEC'sBASIC-PLUS, whileApple BASIC was written bySteve Wozniak based on an HP manual and uses HP's system of string handling.[13][a]
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.[14] TheUS Bureau of Standards released the NBSIR 77-1420test suite to allow vendors to test compliance with the standard.[15] 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 theZilog Z80, better known asMBASIC, which gained compliance with the standard in its 5.0 version.[16]
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 asTrue Basic in 1984. This was bug-ridden and confusing, leadingJerry Pournelle to deride it as "madness"[17] andJohn Dvorak to dismiss it as "sad" and "doomed to failure."[18] Plans to move Minimal BASIC to theInternational Organization for Standardization (ISO) were abandoned,[19] and the ANSI group broke up leaving the original standards inactive.[20]
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.
Like most BASIC implementations, Minimal is based on the underlyingsource code being edited using aline editor and thus every line of code in Minimal has to have aline 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.[21]
Keywords includeREM,DIM,OPTION,DEF ,LET,PRINT,INPUT,READ,DATA,RESTORE,IF...THEN,FOR...TO...STEP...NEXT,GO TO,GO SUB...RETURN,ON...GO TO,RANDOMIZE,STOP andEND.[22]
Programs are required to have anEND as their last line.[23]INPUT may have an optional prompt string, but that is up to the implementation, not part of the standard.[24]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.[25]
Variable names can consist of a single letter, or a letter and a single digit. Two-letter variable names are not allowed.[26] Numbers are limited to the range 10-38 to 1038.[21] String variables can have a maximum of 18 characters.[27] Arrays can be one or two dimensional usingDIM, but only numeric arrays are supported. All variables are normally allocated space in an associated one-dimensional array without usingDIM, they are given space for 11 items, indexes 0 to 10. The lower bound for arrays is typically 0, but usingOPTION BASE 1 can change the index to 1.[28]
There are 11 defined functions;ABS,ATN,COS,EXP,INT,LOG,RND,SGN,SIN,SQR andTAN.[29] 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 andNOT, are not supplied.[10]
User-defined functions usingDEF FN were supported, but only for numerics. No built-in or user functions for strings were available.[30]
This code implements theSieve of Eratosthenes:[31]
1000REM SIEVE OF ERATOSTHENES1010REM MODIFIED FROM QUICK BASIC MATH PROJECT DEMO1020REM2010REM L IS THE LIMIT OF THE SIEVE2020REM WE WILL FIND ALL PRIME NUMBERS UP TO L2030LETL=10002040REM N IS THE SIEVE ITSELF2050DIMN(1000)2060REM FILL THE SIEVE WITH ALL NUMBERS UP TO L2070FORI=1TOL2080LETN(I)=I2090NEXTI2100REM START WITH THE FIRST PRIME NUMBER: 22110LETP=22120PRINTP,2130REM "CROSS OUT" MULTIPLES OF P2140FORI=PTOLSTEPP2150LETN(I)=02160NEXTI2170REM FIND THE NEXT NUMBER NOT CROSSED OUT2180LETP=P+12190IFP=LTHEN22202200IFN(P)<>0THEN21202210GOTO21802220PRINT2230END