BASIC

From Maze

(Difference between revisions)
Jump to: navigation, search
(→The Ethic vs. The Corporation)
(→Line Numbers and Colons: BASIC's Responses to Changing Hardware (Sidebar))
Line 138:Line 138:
== Line Numbers and Colons: BASIC's Responses to Changing Hardware (Sidebar) ==
== Line Numbers and Colons: BASIC's Responses to Changing Hardware (Sidebar) ==
−
Microsoft has used its position as a corporate supporter of BASIC to make many changes to the language beginning with the days of the Altair, adding and removing pieces that became necessary or obsolete as hardware progressed. For example, to allow programs to be written more compactly--an important feature given the Altair's interface, which could literally be painful to program--Microsoft's Altair BASIC introduced the colon (:) as a separator of statements on the same line. This allowed lines such as:
+
Microsoft has used its position as a corporate supporter of BASIC to make many changes to the language, adding and removing components that became necessary or obsolete as hardware progressed. For example, to allow programs to be written more compactly -- an important feature given the Altair's switch and toggle interface, which could literally be painful to program -- Microsoft's Altair BASIC introduced the colon (:) to place separate statements on the same line. Used this way, the colon allowed lines such as:
<code>160 R=16:PRINT"HOW MANY DECKS (1-4)";</code>
<code>160 R=16:PRINT"HOW MANY DECKS (1-4)";</code>
−
This feature was missing from minicomputer BASICs and the ANSI standard, and Kemeny and Kurtz saw it as potentially confusing rather than helpful. When they released their much-revised True BASIC for home computers in 1983, it did not allow multi-statement lines. The colon is, however, important to 10 PRINT; this program could not be written as a concise one-liner without it.
+
Multiple statements on the same line was not possible with minicomputer BASICs and the ANSI standard; Kemeny and Kurtz saw the compression of statements as potentially confusing rather than helpful. When they released their much-revised True BASIC for home computers in 1983, they did not allow multi-statement lines. The colon is, however, important to 10 PRINT; this program could not be written as a concise one-liner without it.
−
Another prominent feature that appears in 10 PRINT is also an artifact of the hardware lying beneath the language. Unlike its punch card-derived predecessors, BASIC didn't require programmers to put things in certain columns; but there was a requirement that a number, such as "10", appear at the beginning of each line. While this facilitated branching by allowing the GOTO and GOSUB statements refer to line numbers where program flow should jump to, BASIC did not actually need line numbers for this purpose. Labels, such as those used in pre-existing languages like assembly, would have sufficed. The line number's real value is seen on a Teletype or other print terminal, or in any environment where full-screen, nonlinear editing is not an option. Line numbers made it easy in those cases to delete existing lines; simply type the line number without any further instructions, and the line disappears. To correct a single existing line, just retype a line with the same line number. To see what code is currently on a particular line, "LIST 50" will do the trick -- although if one had written the line recently, one could also look up or literally "scroll" back to where the line had been printed out.
+
Another prominent feature of 10 PRINT is also an artifact of the hardware underlying the language. Unlike its punch card-derived predecessors, BASIC didn't require programmers to put things in certain columns; yet there was a requirement that a number, such as "10", appear at the beginning of each line. While line numbers made branching possible by allowing GOTO and GOSUB, BASIC did not technically need line numbers for this purpose. Labels, such as those used in pre-existing languages like assembly, would have sufficed. The line number's real value is seen on a Teletype or other print terminal, or in any environment where full-screen, nonlinear editing is not an option. Line numbers made it easy in those cases to delete existing lines; simply type the line number without any further instructions, and the line disappears. To correct a single existing line, just retype a line with the same line number. To see what code is currently on a particular line, "LIST 50" will do the trick -- although if one had written the line recently, one could also look up or literally "scroll" back to where the line had been printed out.
−
The practice of numbering program statements by multiples of five or ten is not merely aesthetic; the insertion of new lines in a program requires that, as the 1964 manual puts it, "the original line numbers <ins>not</ins> be consecutive numbers" (22). Numbering a program 10, 20, 30, and so on ensured that between every existing program statement there was room for nine more. It was an acknowledgement that a program is dynamic rather than fixed and perfect. The ''Commodore 64 User's Guide'' also advises that "it is good programming practice to number lines in increments of 10--in case you need to insert some statements later on" (33).
+
The practice of numbering program statements by multiples of five or ten is not merely rhythmic or aesthetic; the insertion of new lines in a program requires that, as the 1964 manual puts it, "the original line numbers <ins>not</ins> be consecutive numbers" (22). Numbering a program 10, 20, 30, and so on ensured that between every existing program statement there was room for nine more. It was an acknowledgement that a program is dynamic rather than fixed and perfect. The ''Commodore 64 User's Guide'' also advises that "it is good programming practice to number lines in increments of 10--in case you need to insert some statements later on" (33).
−
While line numbers became an iconic feature of BASIC early in the personal computing era, they also contributed to a perception among programmers that the language is limited to simple tasks. Leaving space to add nine new lines of code between every original line may initially seem like plenty of flexibility, but it is rarely enough when programmers have a complex problem to solve. BASIC can still accommodate this situation by allowing the programmer to use GOTO and GOSUB to jump to unused numbers where they can write their new code outside of the existing numbering scheme, then return to the original program flow when it is complete. Unfortunately, the result of doing this is usually what is called spaghetti code--so named because the flow chart of a program becomes so confused and self-referential that all the lines look like a plate of spaghetti, making it nearly unintelligible.
+
While line numbers became an iconic feature of BASIC early in the personal computing era, they also contributed to a perception among programmers that the language is limited to simple tasks. Leaving space to add nine new lines of code between every original line may initially seem like plenty of flexibility, but it is rarely enough when programmers have a complex problem to solve. BASIC can still accommodate this situation by allowing the programmer to use GOTO and GOSUB to jump to as of yet unused numbers for a separate routine and then return to the original program flow when complete. Unfortunately, too many GOTO sub-routines can result in "spaghetti code" -- so named because the flow chart of a program becomes so confused and self-referential that all the lines look like a plate of spaghetti, making the program nearly unintelligible.
−
In 1991 Microsoft realized that the perception of BASIC as limited to simple programs was holding the language back, and that this perception was largely due to a feature of the language that was no longer even necessary. Text editors that could display and allow access to screenfuls, or windowfuls, of lines had long been available, and line numbers were now doing more damage than good. As part of their 1991 QBasic the company deprecated line numbers, replacing them with the assembly-like text labels that had originally been dismissed as inconvenient on the hardware of the era.
+
In 1991 Microsoft realized that the perception of BASIC as limited to simple programs was holding the language back, and that this perception was largely due to a feature of the language that was no longer even necessary. Text editors that could display and allow access to screenfuls, or windowfuls, of lines had long been available, and line numbers were now doing more damage than good. As part of their 1991 QBasic the company deprecated line numbers, replacing them with the assembly-like text labels that had once been dismissed as inconvenient.
The simple fact that 10 PRINT includes both the colon and the line number -- features that have been added and removed from BASIC in response to hardware changes -- signals that 10 PRINT is from a particular time and related to a specific era of computing caught between competing input mechanisms. Its heritage and provenance is literally written right into its code.
The simple fact that 10 PRINT includes both the colon and the line number -- features that have been added and removed from BASIC in response to hardware changes -- signals that 10 PRINT is from a particular time and related to a specific era of computing caught between competing input mechanisms. Its heritage and provenance is literally written right into its code.

Revision as of 22:23, 15 July 2011

View this revision of BASIC.

Personal tools