BASIC

From Maze

(Difference between revisions)
Jump to: navigation, search
(→Remembering 10 PRINT (Sidebar))
(→Line Numbers in BASIC)
Line 142:Line 142:
Ultimately, BASIC became what it was in 1982 thanks to the institution of higher education where it was first developed, the corporation that implemented it and licensed it for use on home computers (including the Commodore 64), and, significantly, the hacker ethic of code sharing that allowed BASIC programs to circulate freely.
Ultimately, BASIC became what it was in 1982 thanks to the institution of higher education where it was first developed, the corporation that implemented it and licensed it for use on home computers (including the Commodore 64), and, significantly, the hacker ethic of code sharing that allowed BASIC programs to circulate freely.
−
== Line Numbers in BASIC ==
+
== Line Numbers in BASIC (sidebar) ==
 +
 +
Microsoft has used its position as a corporate supporter of BASIC to make many changes to the language since the days of the Altair, adding and removing pieces that became necessary or obsolete as hardware progressed. One of the features that is most associated with BASIC, the line number, falls into this category.
 +
 +
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.
 +
 +
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).
 +
 +
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.
 +
 +
In 1991 Microsoft realized that the perception of BASIC as limited to simple programs was holding the language back, and that this perception waslargely due to a feature of the language that was no longer even necessary. Nonlinear text editors 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.
== Commodore BASIC==
== Commodore BASIC==

Revision as of 21:28, 11 July 2011

View this revision of BASIC.

Personal tools