BASIC
From Maze
(Difference between revisions)
(→Altair BASIC and Micro-Soft) | (→CHR$ and the Dollar Sign in BASIC (Sidebar)) | ||
| Line 55: | Line 55: | ||
== CHR$ and the Dollar Sign in BASIC (Sidebar) == | == CHR$ and the Dollar Sign in BASIC (Sidebar) == | ||
| − | In designing BASIC, Kemeny and Kurtz needed to distinguish variables that hold numeric values from those that hold strings of text. They chose to have string variables and string functions end with "$," so that a string variable might be named A$ and the function that produced one-character strings based on ASCII values was called CHR$. They selected the dollar sign because "There were not so many keys on a Teletype, and we needed to find one that had not yet been used for BASIC. Of the few remaining ones, none seemed very appropriate. Then one of us observed that $ looks like S for string." (Kemeny & Kurtz 28) | + | In designing BASIC, Kemeny and Kurtz needed to distinguish variables that hold numeric values from those that hold strings of text. They chose to have string variables and string functions end with a "$," so that a string variable might be named A$ and the function that produced one-character strings based on ASCII values was called CHR$. They selected the dollar sign because there "were not so many keys on a Teletype, and we needed to find one that had not yet been used for BASIC. Of the few remaining ones, none seemed very appropriate. Then one of us observed that $ looks like S for string" (Kemeny & Kurtz 28). |
| − | Computers are fundamentally machines to add and multiply; the accounting and commercial functions that they carry out are much higher-level. So it is a curious circumstance that the Commodore 64 keyboard, like modern North American keyboards, has a dollar sign on it but does not have a multiplication sign. Instead, the asterisk (*), a typographical mark used to indicate a footnote, is pressed into service as the symbol for multiplication. | + | Computers are fundamentally machines that add and multiply, so it is a curious circumstance that the Commodore 64 keyboard, like modern North American keyboards, has a dollar sign on it but does not have a multiplication sign. Instead, the asterisk (*), the typographical mark once used to indicate a footnote, is pressed into service as the symbol for multiplication. |
| − | Kemeny and Kurtz point to part of the reason for this. When they were developing BASIC, they may have been looking at a just-released ASR-33 Teletype -- this light-duty office model was used with the Dartmouth Time-sharing System and many other minicomputers. But even though widespread interactive (as opposed to batch) processing was a novelty, teletypewriters has been used as interfaces to computers long before this. Various sorts of TTYs, teleprinters, or "printing telegraphs" were used commercially as a means of textual communication beginning in the 1910. These systems were used to transmit dollar amounts much more often than they were used for sending mathematical equations. They were based on pre-ASCII characters codes that came from telegraphy, the two International Telegraph Codes. These were the 1870 Baudot Code and the 1901 revision of this for a typewriter keyboard, Murray Code. Murray Code is a 5-bit code that includes two characters that allow "shifting" into alternate sets. A shifted "D" represents "$" in Murray Code. | + | Why would a keyboard have a dollar sign but not a multiplication sign? Even though interactive processing (as opposed to batch processing with punched cards) was a novelty, teletypewriters had been used as interfaces to computers long before the 1960s. Various sorts of TTYs, teleprinters, or "printing telegraphs" were used commercially as a means of textual communication beginning in the 1910s. Based on pre-ASCII characters codes that came from telegraphy, these systems were used to transmit dollar amounts much more frequently than they were used for sending mathematical equations. Murray Code, the 1901 revision of the standard 1870 telegraph code, included two characters that allowed "shifting" into alternate sets. A shifted "D" would become a "$" in Murray Code. |
| − | The origin of the Teletype in the United States offers another reason that the dollar sign was on Typetypes and was later used in computing and in BASIC. The original, North American Commodore 64 keyboard also sported a pound sterling sign (£), absent from other U.S. computers of the time. It seemed to be a clear indicator of Commodore's plans to sell the computer in the United Kingdom, although it had a precedent in Murray Code, which also features a pound sterling sign. | + | Interestingly, the original, North American Commodore 64 keyboard sported a pound sterling sign (£), a figure absent from other U.S. computers of the time. The presence of this key is a clear indicator of Commodore's plans to sell its computers in the United Kingdom, although the key had a precedent in Murray Code, which also features a pound sterling sign. |
The dollar sign is still used in some of today's workhorse programming languages, such as Perl and PHP. In both of these, it is used to indicate a variable by being placed at the beginning, rather than the end, of the variable name. In Perl it specifically indicates a ''scalar'' variable, since $ looks like S for scalar. | The dollar sign is still used in some of today's workhorse programming languages, such as Perl and PHP. In both of these, it is used to indicate a variable by being placed at the beginning, rather than the end, of the variable name. In Perl it specifically indicates a ''scalar'' variable, since $ looks like S for scalar. | ||
