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,
History
Previous developments
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.[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 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.[6]
Interpreters quickly became common on smaller machines and minicomputers. Other vendors quickly copied the HP dialect, notably
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.[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.
Arthur Luehrmann[9]
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 GO TO
and GOTO
were the same thing, in this case stating that goto statement = GO space* TO line number
, meaning GOTO
, GO TO
and even GO TO
were identical.[10] 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.[9]
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.[11]
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[12] 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.[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] The US Bureau of Standards released the NBSIR 77-1420 test 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 the Zilog Z80, better known as MBASIC, 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 as
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.[21]
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
.[22]
Programs are required to have an END
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 1E-38 to 1E38.[21] String variables can have a maximum of 18 characters.[27] 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.[28]
There are 11 defined functions; ABS
, ATN
, COS
, EXP
, INT
, LOG
, RND
, SGN
, SIN
, SQR
and TAN
.[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
and NOT
, are not supplied.[10]
User-defined functions using DEF FN
were supported, but only for numerics. No built-in or user functions for strings were available.[30]
Example
This code implements the Sieve of Eratosthenes:[31]
1000 REM SIEVE OF ERATOSTHENES
1010 REM MODIFIED FROM QUICK BASIC MATH PROJECT DEMO
1020 REM
2010 REM L IS THE LIMIT OF THE SIEVE
2020 REM WE WILL FIND ALL PRIME NUMBERS UP TO L
2030 LET L = 1000
2040 REM N IS THE SIEVE ITSELF
2050 DIM N(1000)
2060 REM FILL THE SIEVE WITH ALL NUMBERS UP TO L
2070 FOR I = 1 TO L
2080 LET N(I) = I
2090 NEXT I
2100 REM START WITH THE FIRST PRIME NUMBER: 2
2110 LET P = 2
2120 PRINT P,
2130 REM "CROSS OUT" MULTIPLES OF P
2140 FOR I = P TO L STEP P
2150 LET N(I) = 0
2160 NEXT I
2170 REM FIND THE NEXT NUMBER NOT CROSSED OUT
2180 LET P = P + 1
2190 IF P = L THEN 2220
2200 IF N(P) <> 0 THEN 2120
2210 GOTO 2180
2220 PRINT
2230 END
Notes
References
Citations
- ^ Kurtz 1981, p. 532.
- ^ Kurtz 1981, pp. 532, 534.
- ^ McCracken 2014.
- ^ "IBM VS the World: That's How It Is". Computerworld. 5 December 1973. Archived from the original on 28 January 2022. Retrieved 26 April 2022.
- ^ Leibson, Steve (2017). "HP: The Accidentally, On-Purpose Computer Company". HP9825.COM. Archived from the original on 2019-10-21. Retrieved 2022-04-26.
- ^ "Hewlett-Packard 2100 Processor Description, 1972" (PDF). Archived (PDF) from the original on 2021-04-12. Retrieved 2020-08-18.
- ^ Savetz, Kevin (April 2013). "Dave Ahl and Betsy Ah" (Interview). Archived from the original on 2022-03-31. Retrieved 2022-04-26.
- ^ ECMA 1978, p. iii.
- ^ a b Luehrmann 1984, p. 173.
- ^ a b ECMA 1978, p. 15.
- ^ Luehrmann 1984, p. 171.
- ^ Fridson 1999, p. 116.
- ^ a b Wozniak 2014.
- ^ ECMA 1978, p. i.
- ^ Gilsinn & Sheppard 1978.
- ^ BASIC-80 Reference Manual. Microsoft. 1981. Archived from the original on 2022-05-21. Retrieved 2022-04-26.
- ^ Pournelle 1985, p. 366.
- ^ Dvorak 1984, p. 88.
- ^ "ISO 6373:1984". Archived from the original on 2021-03-03. Retrieved 2022-04-26.
- ^ "ECMA-55 Minimal BASIC". ECMA International. Archived from the original on 2022-04-03. Retrieved 2022-04-26.
- ^ a b ECMA 1978, p. 6.
- ^ ECMA 1978.
- ^ ECMA 1978, p. 5.
- ^ ECMA 1978, p. 22.
- ^ ECMA 1978, p. 17.
- ^ ECMA 1978, p. 8.
- ^ ECMA 1978, p. 9.
- ^ ECMA 1978, p. 25.
- ^ ECMA 1978, p. 11.
- ^ ECMA 1978, p. 13.
- ^ Ham, John Gatewood (May 15, 2015). "ERATOSTHENESE.BAS". Sourceforge. Archived from the original on 2022-04-26. Retrieved 2022-04-26.
Bibliography
- Dvorak, John (19 November 1984). "Sad But True Basic". InfoWorld. p. 88.
- Fridson, Martin S. (1999). How to be a billionaire: proven strategies from the titans of wealth. John Wiley and Sons. ISBN 0-471-33202-X.
- Gilsinn, David E.; Sheppard, Charles L. (1978). NBSIR 78-1420-1: NBS Minimal BASIC Test Programs - Version 1 User's Manual: Vol. 1 - Test System Overview (PDF) (Technical report). National Bureau of Standards.
- Kurtz, Thomas (1981). "BASIC". In Wexelblat, Richard (ed.). History of Programming Languages I. ISBN 0127450408.
- Luehrmann, Arthur (September 1984). "Structured programming in Basic; part 4: ANSI Basic, Macintosh Basic, and True Basic". Creative Computing. pp. 171–177. Archived from the original on 2012-12-30.
- McCracken, Harry (29 April 2014). "Fifty Years of BASIC, the Programming Language That Made Computers Personal". Time.
- Pournelle, Jerry (September 1985). "PCs, Peripherals, Programs, and People". Byte. pp. 366–373. Retrieved 20 March 2016.
- Wozniak, Steven (1 May 2014). "How Steve Wozniak Wrote BASIC for the Original Apple From Scratch". Gizmodo.
- ECMA (January 1978). ECMA-55: Minimal BASIC. Archived from the original (PDF) on 2019-07-24.
Further reading
- ANSI X3.113-1987: Programming Languages - Full BASIC (PDF). ANSI. 1987.
- Gilsinn, David E.; Sheppard, Charles L. (1978b). NBSIR 78-1420-4: NBS Minimal BASIC Test Programs - Version 1 User's Manual: Vol. 4 - Mathematical and User Defined Functions, Compound Expressions (PDF) (Technical report). National Bureau of Standards.
- ECMA (June 1986). Standard ECMA-116: BASIC (PDF). Archived from the original (PDF) on 2011-10-14.
- Ham, John Gatewood (August 30, 2021). An Introduction to Programming with ECMA-55 Minimal BASIC (PDF).