Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Dartmouth BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Versions== ===First Edition=== The original version, retroactively known as version one, supported the commands <code>LET</code>, <code>PRINT</code>, <code>END</code>, <code>FOR...NEXT</code>, <code>GOTO</code>, <code>GOSUB...RETURN</code>, <code>IF...THEN</code>, <code>DEF</code>, <code>READ</code>, <code>DATA</code>, <code>DIM</code>, and <code>REM</code>. It included basic math instructions, {{key|+}}, {{key|-}}, {{key|*}} and {{key|/}}, as well as the up-arrow for exponents "...since on a teletype typewriter it is impossible to print superscripts."{{sfn|Kurtz|1981|p=523}} In modern varieties, the up-arrow is normally replaced by the "hat" character, {{key|^}}. Exponents took the absolute value of the number before calculation, so to calculate {{code|-X^3}}, one had to use {{code|X*X*X}}. There was a further problem in the exponent function that treated {{code|-X^2}} as {{code|(-X)^2}} as opposed to the correct [[order of operations]] {{code|-(X^2)}}, which was not corrected until the third release.{{sfn|Kurtz|1981|p=523}} The <code>INT()</code> function always truncated towards zero.{{sfn|Kurtz|1981|p=524}} The language had a number of idiosyncrasies of its own. In contrast to later versions, the <code>LET</code> command was required on all statements lacking another command, so {{code|2=basic|1=10 A=5*5}} was not valid in this version.{{sfn|Kurtz|1981|p=524}} The <code>PRINT</code> statement used the comma when printing multiple variables, advancing to the next of five "zones". The comma was not needed in the case where one was printing a prompt and single value, so {{code|2=basic|PRINT "value of A is "A}} was valid. A somewhat hidden feature was that all variables were capable of representing arrays (vectors) of up to ten elements (subscripts 1 to 10, changed to 0 to 9 in the Second Edition) without being declared that way using <code>DIM</code>. <code>DIM</code> was only needed if a different vector size was required.{{sfn|Kurtz|1981|p=525}}{{efn|This feature was found on most BASICs based on Dartmouth, but was rare on those that were created independently.}} Variable names were limited to a single letter or a letter followed by a digit (286 possible variable names). User functions could only have a single letter, thus {{code|FNA}} through {{code|FNZ}}. All operations were done in [[floating point]]. On the GE-225 and GE-235, this produced a precision of about 30 bits (roughly ten digits) with a base-2 exponent range of -256 to +255.<ref>{{cite web|last=Kurtz|first=Thomas|title=BASIC Commands: The Original-Original Version|url=https://www.dartmouth.edu/basicfifty/commands.html#:~:text=All%20arithmetic%20was%20done%20in,of%20%2D256%20to%20%2B255.&text=Ten%20numeric%20functions%20were%20provided.}}</ref> Additionally, due to the GE-235's word size being 20-bits and using a [[six-bit character code]], the language enshrined the use of three-letter function names because that allowed the storage of three six-bit characters in a 20-bit word (using 18 bits). This is why BASIC functions are three letters, like <code>INT</code> or <code>SQR</code>, something that remained in the many varieties of the language long after they left the GE-235.{{sfn|Kurtz|1981|p=524}} ===Second Edition, CARDBASIC=== The Second Edition of BASIC (though not referred to as such at the time) only made minimal changes. Released in October 1964, it could start arrays at subscript 0 instead of 1 (useful for representing [[polynomial]]s) and added the semicolon, {{key|;}}, to the <code>PRINT</code> statement.{{sfn|Kurtz|1981|p=526}} Unlike later implementations where this left space between items, the semicolon advanced printing to the next multiple of three characters, which was useful for "packing" more numbers into a line of output than the existing comma separator.{{sfn|Man4}} The three-character size was a side-effect of the GE-235's 20-bit [[Word (computer architecture)|word size]], which stored three six-bit characters. Skipping to the next three-character column was accomplished simply by moving to the next word in memory.{{sfn|Kemeny|Kurtz|1985|p=24}} The October version also included a separate definition for CARDBASIC, which was simply a version of BASIC for use on card-based workflows. CARDBASIC was almost identical to the interactive version, with the exception being that it did not include the zero-based arrays. More important to the language's future, CARDBASIC added the <code>MAT</code> commands that worked with numerical matrices. CARDBASIC was not developed further, as the entire idea of BASIC had been to be interactive.{{sfn|Kurtz|1981|p=526}} ===Third Edition=== The Third Edition, released in 1966 and the first to use the "edition" naming, was the first designed specifically with the intent of running on the new GE-635 computer which was due to arrive shortly. This version includes the <code>MAT</code> functions from CARDBASIC, and they can now use 0 as a subscript.{{sfn|Kurtz|1981|p=527}} The new <code>SGN</code> function gave the sign of its argument (positive?0 and negative?1), while <code>RESTORE</code> was added to "rewind" the position of <code>READ/DATA</code>. The exponentiation problem was fixed, so {{code|-X^2}} would be interpreted as {{code|-(X^2)}}.{{sfn|Kurtz|1981|p=527}} Additionally, the <code>INT</code> function was changed to be a true floor, as opposed to trim-toward-zero, which allowed rounding to be implemented with <code>INT(X+0.5)</code>.{{sfn|Kurtz|1981|p=524}} The major change in this version was the new <code>INPUT</code> statement, which parsed numeric values, making the language truly interactive during execution for the first time; previously the only control one had during execution was to type <code>STOP</code> in the monitor. Additionally, the system now allowed, and encouraged, loops to be indented, a feature that was not seen on most other versions of BASIC.{{sfn|Kurtz|1981|p=528}} ===Fourth Edition=== The Third Edition remained in use through the GE-235's lifetime into the fall of 1967. However, as plans were made to receive the GE-635, an experimental version was created on the 635 in the spring of 1967. This version was a partnership between GE and Dartmouth, with GE contributing a new operating system as well as a number of features of BASIC from their own Mark 1 BASIC efforts.{{sfn|Kurtz|1981|p=528}} This version, initially published as a supplement to the Third Edition, added the <code>RANDOMIZE</code> command to "seed" the <code>RND</code> function, and the <code>ON...GOTO</code> "computed goto" that closely matched the similar feature in FORTRAN. This version also allowed <code>ON...THEN</code>, arguing that <code>IF...THEN</code> did not require the <code>GOTO</code> then it would not be required here. The new <code>TAB</code> function moved printing to a given column, from 0 to 74.{{sfn|Kurtz|1981|p=528}} Another internal change was to once again change the <code>MAT</code> to be 1-based; one could use the 0th index, but it would normally be ignored by the various commands.{{sfn|Kurtz|1981|p=529}} The major addition for this version was string variables, along with changes to the <code>READ/DATA</code> statements which could store strings in them and the <code>INPUT</code> statement to read them interactively. One feature of the string system was that trailing spaces were deliberately ignored in comparisons, so that "YES" and "YES " were considered equal.{{sfn|Man4|p=66}} This was later realized to be a grave error.{{sfn|Kurtz|1981|p=529}} String variables were indicated by the dollar sign, e.g. {{code|A$}}, simply because they were running out of characters that could be found on most keyboards. Someone pointed out that the $ looked like the S in "String", and that was that.{{sfn|Kemeny|Kurtz|1985|p=28}} String manipulation was handled through the new {{code|CHANGE}} command. This converted the string value in a variable to the equivalent set of ASCII values. The numeric array could then be manipulated and converted back to a string. For instance, this code produces "is" on the console: {{sxhl|2=basic|1= 100 LET S$ ="Now is the time" 110 CHANGE S$ TO S 120 LET T(1) = S(5) 130 LET T(2) = S(6) 140 LET T(0) = 2 150 CHANGE T TO T$ 160 PRINT T$ }} Line 140 sets the string length to 2, which has to be managed by the user. The first character is in T(1). While this system is flexible, it was by no means convenient to use. Later versions would address this with new functionality.{{sfn|Kemeny|Kurtz|1985|p=29}} Minor changes in this version changed the semicolon in <code>PRINT</code> statements to do "close packing" of output with no spaces,{{sfn|Kemeny|Kurtz|1985|p=24}}{{sfn|Man4|p=64}} and the use of the apostrophe as a short-form <code>REM</code>.{{sfn|Man4|p=52}}{{efn|It is not clear if the apostrophe was used in previous versions, the Revision 4 manual is the first to mention it explicitly.}} The official Fourth Edition did not appear until 1968, which added several new features on top of the previous additions. This included the ability to define multi-line functions with the <code>DEF</code> command, and the powerful <code>CHANGE</code> statement that treated strings as arrays of [[ASCII]]-like codes so individual characters could be operated on without looping over the entire string.{{sfn|Kurtz|1981|p=529}} This was also the only string manipulation function; to extract a single character or substring, one had to use <code>CHANGE</code> to convert it into an array of numbers, manipulate that array, and then convert it back. This was the reason MAT was 1-based again; the length of the string was placed in location zero, and it needed to be ignored normally.{{sfn|Man4|p=67}} ===Fifth Edition=== The Fifth Edition, from late 1970, once again started as two supplements to the Fourth Edition, from February and April 1969.{{sfn|Kurtz|1981|p=529}} The major change was the introduction of file handling. Previously, any pre-defined data that had to be used in the program had to be placed in the {{mono|DATA}} lines and then read in one-at-a-time using the {{mono|READ}} command. This feature could be used to read files in a similar fashion. The {{mono|INPUT}} command could now read a single item from a file and {{mono|PRINT}} could write one. {{sfn|Kemeny|Kurtz|1985|p=31}} Files were opened through the new {{code|FILES}} keyword, which was followed by a list of string constants describing file names. As these were constants, changing the file name demanded the code be changed to match. The names were assigned numbers, the first name became file #1, and so on. Two file formats were supported, random-access and linear. A linear file was treated as a text file would be today, one could {{code|LINPUT #1: A$}} to read a line of text into a string variable, and then {{code|PRINT A$}} to output it to the terminal.{{sfn|Kemeny|Kurtz|1985|p=31}} Later versions added the {{code|FILE $1,name$}} to allow files to be specified by strings, although for a time this required a {{code|FILES *}} near the top of the program to indicate you were using this format.{{sfn|Kemeny|Kurtz|1985|p=32}} For random access files, the name had to specify the type of data within; {{code|%}} indicated it contained binary data, while {{code|$num}} indicated it should be read as strings with a maximum length of {{code|num}}.{{sfn|Kemeny|Kurtz|1985|p=31}} The {{mono|READ}} and {{mono|WRITE}} could be positioned anywhere in a random-access file with the {{mono|RESET}} command, while the current location was returned by the {{mono|LOC}} function, and the file length by {{mono|LOF}}. During sequential reads, one could also test whether it was at the end of the file using <code>IF END THEN...</code>.{{sfn|Kurtz|1981|p=530}} Another major change was the ability for one BASIC program to call another using the {{mono|CHAIN}} command, and pass variables to it using the {{mono|COMMON}} list. It was later realized that this basic concept had a number of problems, but it was nevertheless used to write some large programs.{{sfn|Kurtz|1981|p=530}} String handling received a major update. The new {{code|SEG$}} command returned a new string clipped out of another. In the example above, the string "is" is extracted from a larger string. Using the new command, this can be reduced to {{code|LET T$ {{=}} SEG$(S$,5,6)|basic}}, which works similarly to the {{code|MID$}} function found in most dialects ({{code|MID$(S$,5,2)}}). SEG$ uses first and last indices; MID$ uses first index and length. {{code|LEN}} returned the length of a string, which was otherwise now handled internally and did not require calculation in most cases, and {{code|POS}} returned the position of one string within another, which in most dialects was handled by {{code|SUBSTR}}. The ampersand, {{code|&}}, was introduced for [[Concatenation|string concatenation]].{{sfn|Kemeny|Kurtz|1985|p=29}} Numerous more minor changes were also added. Among these were two-dimensional string arrays, as opposed to one-dimensional in the previous version, as well as the ability to use the {{mono|DEF}} to define string-based functions as well as mathematical. New system-oriented functions included {{mono|CLK$}}, {{mono|DAT$}} to work with times and dates, {{mono|TIM}} which returned the elapsed time, and {{mono|USR$}} which returned the user number, what would today be the username. New string functions included {{mono|STR$}}, {{mono|VAL}}, {{mono|ASC}}, which are common in modern BASIC dialects. The {{key|'}} as a short form for {{mono|REM}} also appeared in this version.{{sfn|Kurtz|1981|p=530}} ===Sixth Edition=== Work on the Sixth Edition began in the fall of 1969 before the Fifth Edition was finalized. A complete specification was written beforehand for the new version. This contrasts with previous versions where the specification documents were based on the changes in the compiler. This version was worked on by Kemeny and Kurtz as well as several former students who returned as faculty: Stephen Garland, John McGeachie, and Robert Hargraves. It was given considerable time to mature, with a beta version running for three months during the summer of 1971, before it was finally released on 21 September 1971. As a result of this maturity, Kurtz described it as "probably the best-designed and most stable software system Dartmouth has ever written."{{sfn|Kurtz|1981|p=531}} One of the biggest changes was the replacement of the earlier <code>CHAIN</code> concept with the much better-defined <code>CALL</code> which operated in a fashion similar to <code>GOSUB</code>, but it referred to a function name rather than a line number. The functions were defined using <code>SUB...SUBEND</code>, and took arbitrary [[Parameter (computer programming)|parameters]] in the call rather than using [[global variable]]s via <code>COMMON</code> declarations. Another major change was to use file handles (numbers) created with the <code>FILE</code> command which is similar to <code>OPEN</code> which is found in most modern BASICs.<code>PRINT USING</code> provided formatted output in a fashion somewhat similar to FORTRAN,{{sfn|Elliott|1988|p=134}} while {{code|LINPUT}} accepted input with no interpretation, allowing commas, semicolons, and even BASIC code to be typed in.{{sfn|Kemeny|Kurtz|1985|p=26}} The Sixth Edition was essentially the last version of the original BASIC concept. It remained unchanged for many years. Later versions were significantly different languages.{{sfn|Kurtz|1981|p=531}} ===SBASIC=== In 1976, Stephen Garland collected a number of [[structured programming]] additions to create Dartmouth Structured BASIC, or SBASIC.{{sfn|Garland|1976}} The primary goal was to replace the control structures based on <code>IF...THEN</code> and <code>GOTO</code> with a variety of block-oriented structures. It did this using a precompiler that took SBASIC source code, converted that to 6th Edition BASIC, and then compiled and ran that as normal. SBASIC also added a number of graphics features, based on the <code>PLOT</code> command that had been added by other programmers.{{sfn|Garland|1976|p=1}} Block structures were terminated by matching statements as was the case in [[ALGOL 68]], as opposed to the generic block structures found in languages like [[Pascal (programming language)|Pascal]] or [[C (programming language)|C]]. For instance, the <code>DO WHILE...</code> spanned multiple lines until it ended with a <code>LOOP</code>.{{sfn|Garland|1976|p=4}} The <code>DO</code> loop could also be bottom exited by removing the <code>WHILE</code> or <code>UNTIL</code> and placing the conditional at the bottom on the <code>LOOP</code>. Infinite loops were supported using <code>DO FOREVER</code> or <code>LOOP FOREVER</code>.{{sfn|Garland|1976|p=5}} "Original" Dartmouth BASIC did not allow statements after a <code>THEN</code>, only a line number to branch to. SBASIC allowed any statement, so for instance {{code|2=basic|1=IF X < 5 THEN X=X+1}}.{{sfn|Garland|1976|p=6}} This basic expansion to the <code>IF...THEN</code>, pioneered in 1972 with [[BASIC-PLUS]],<ref>{{cite book|url=https://archive.org/details/bitsavers_decpdp11rsSICPLUSLangManOct72_10455777|title=BASIC-PLUS Language Manual|publisher=Digital Equipment Corporation|year=1972|location=Maynard, Massachusetts|type=PDF|pages=3β13|ref=CITEREFPLUS1972}}</ref> was already widely supported by most variety of BASICs by this point, including [[microcomputer]] versions that were being released at this time. On top of this, SBASIC added block-oriented <code>IF</code> by placing the <code>THEN</code> on a separate line and then ending the block with <code>CONTINUE</code>.{{sfn|Garland|1976|p=7}} On top of this, SBASIC added the <code>SELECT CASE</code> mechanism that survives to this day in [[Visual Basic .NET]].{{sfn|Garland|1976|p=10}} SBASIC also added a number of graphics commands intended to be used with [[plotter]]s. This required the <code>PLOTTER "plottername"</code> to direct subsequent commands to a selected device, and the <code>WINDOW...</code> to set up its parameters. From then on, <code>PLOT X,Y</code> would produce dots on the selected plotter, while adding the semicolon at the end of the statement, as used in <code>PRINT</code>, would leave the pen on the paper and produce a line, for instance <code>PLOT 10,10;20,20</code>.{{sfn|Garland|1976|p=21}}<ref>Stephen J. Garland and Arthur W. Luehrmann, "Graphics in the BASIC language," ''Computer Graphics'' (quarterly report of SIGGRAPH-ACM) 8:3, pages 1β8, 1974.</ref> SBASIC eventually formed the basis of the 1987 [[ANSI BASIC|ANSI X3.113-1987 Standard for Full Basic]], which extended the earlier 1978 ANSI ANSI X3.60-1978 Standard for Minimal Basic. The long delay in producing that standard, along with the lack of regard among computer scientists for unstructured Basic, led the College Board committee developing the [[AP Computer Science|Advanced Placement Course in Computer Science]], which Garland chaired, to opt for requiring Pascal and not allowing Basic as the language for the course.<ref>{{cite magazine |magazine=InfoWorld |date=6 September 1982 |first=Scott |last=Mace |title=College Board developing Pascal-based AP course |page=29 |url=https://books.google.com/books?id=CDAEAAAAMBAJ&pg=PA29}}</ref><ref>Stephen J. Garland, "Advanced Placement Computer Science," ''Computers in Mathematics Education'', Viggo P. Hansen and Marilyn J. Zweng (editors), pages 194β201. Yearbook of the National Council of Teachers of Mathematics, 1984.</ref> Garland used SBASIC to teach the introductory course in computer science at Dartmouth,<ref>Stephen J. Garland, ''Introduction to Computing and Basic Programming'', Program in Computer and Information Science, Dartmouth College, 1982.</ref><ref>Stephen J. Garland, "Languages for first courses in computer science: Basic," ''Abacus'' 1:4, pages 39β49, Summer 1984.</ref> but rewrote his textbook for the course in Pascal<ref>Stephen J. Garland, ''Introduction to Computer Science with Applications in Pascal'', Addison-Wesley, Reading, MA, 1986.</ref> so that it could be used to teach the AP course. ===Seventh Edition=== Garland's SBASIC was a pre-compiler written in SBASIC source code itself. The system would read SBASIC source, write the corresponding 6th Edition code, and then compile that output. The Seventh Edition, released in 1980, was a version of SBASIC that was a stand-alone compiler of its own. It added a number of additions of its own. Most of the changes were further elaborations on the system for calling external programs and "overlays" that could be used to break up a program into parts. In this version, <code>SUB</code>s sharing a single file effectively shared data between them. This provided a modicum of [[data hiding]] within the group of routines. This separation would today be known as a module.{{sfn|Elliott|1988|p=135}} In addition, this edition added structured error handling and arbitrary matrix math in <code>LET</code> statements, so one could <code>LET A = M*4</code> where M was a matrix variable, and the statement would output another matrix into A with all the elements in M scaled by 4. Finally, another major update was the use of [[activation record]]s for subroutines which made [[recursion]] possible.{{sfn|Elliott|1988|p=135}} ==={{Anchor|ANSI BASIC}}ANSI BASIC, Eighth Edition=== <!-- Other articles link here. --> By the early 1970s, the number of BASIC implementations had grown to dozens, all of which had their own changes to the basic concept introduced in the original version. Most of these were based on the Fifth Edition, although they often lacked the MAT instructions and the ability to indent code. GE was one of these companies; they released their Mark II systems with the 5th edition rather than waiting for the 6th to arrive a few months later.{{sfn|Marconi}} BASIC-PLUS on the DEC platform was perhaps the closest implementation, including the MAT commands for instance, but then added a number of changes that were not backward-compatible.<ref name=plus /> After the release of the 6th edition, Kurtz became involved in an effort to define a standard BASIC. An [[American National Standards Institute]] (ANSI) working group, X3J2, formed in January 1974, and a corresponding [[Ecma International|European Computer Manufacturers Association]] (ECMA) group, TC21, that September. The goal at that time was to produce two related standards. Minimal BASIC would be similar to the Second Edition, but adding strings, a standard to which practically every BASIC would already be able to conform. Standard BASIC would add more functionality to produce something more in keeping with the real BASIC varieties seen in the market.{{sfn|Marconi}} The process was slow, and the first draft of Minimal BASIC was not published until January 1976, leading to it being officially adopted in December 1977 by ECMA, and 1979 by ANSI as X3.60-1978. Minimal BASIC was similar to the 3rd edition, including string variables, while lacking MAT and other advanced features.<ref>{{cite book |title=Minimal BASIC |date=January 1978 |publisher=ECMA |url=https://www.ecma-international.org/publications/files/ECMA-ST-WITHDRAWN/ECMA-55,%201st%20Edition,%20January%201978.pdf}}</ref> In contrast, Standard BASIC had many new features that did not exist in other BASICs, and many of these were poorly considered and the subject of some criticism. For instance, the standard included a line-continuation character, but chose the ampersand, {{key|&}}, which was also used for string concatenation. Using these in a single line could lead to very confusing code.<ref>{{cite journal |first=Kurt |last=Guntheroth |title=The New ANSI BASIC Standard |date= July 1983 |volume=18 |issue=7 |doi=10.1145/988216.988221 |journal=ACM SIGPLAN Notices |pages=50β59|s2cid=31236801 }}</ref> By this time, the release of the first [[microcomputer]] systems in 1975 had quickly led to the introduction of [[Altair BASIC]], the first version of what would soon be known as [[Microsoft BASIC]]. MS BASIC was patterned on BASIC-PLUS, and thus ultimately the Fifth Edition, but lacked indenting, MAT, and other features. It also added the <code>LEFT$</code> and <code>RIGHT$</code> functions, breaking the three-letter convention. As the number of microcomputers grew, and turned into the [[home computer]] market in the late 1970s, MS BASIC became the ''de facto'' standard.{{sfn|Marconi}} With this rapid change in the market, the Standard BASIC effort slowed further and was not formally ratified until 1987 as X3.113-1987. By this time, there was no real purpose to the standards; not only was MS BASIC everywhere, but by the mid-1980s the use of BASIC was declining as shrinkwrap software took over from type-in programs. Both standards were eventually withdrawn.{{sfn|Marconi}} In spite of the eventual failure of the ANSI efforts, the draft of Standard BASIC was implemented at Dartmouth as the Eighth Edition in 1982.{{sfn|Elliott|1988|p=135}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)