Introduction

From Maze

Revision as of 12:51, 31 July 2011 by Nickm (Talk | contribs) (→One Line)
Jump to: navigation, search

Even those who have no interest in the playful, aesthetic, and educational dimensions of computing cannot ignore the cultural relevance of code. Computer programs not only function to process and display critical data, to facilitate communication, to monitor and report on sensor networks, and to shoot down incoming missiles - they also have an existence as texts that are read by the original programmer, others who maintain and modify them, and in many cases wider and wider circles of meaning-seekers. We now live in a world where citizens examine the leaked source code that causes our voting machines to function. We find it unremarkable that particular snippets of code written by scientists are quoted in an attempt to demonstrate that climate change is a scam. It is no longer tenable to pretend that computer code is purely technical, without social, political, cultural, or other significant dimensions.

"So why bother trying to understand this line of code?" If computer code embeds stories, then every symbol within them helps illuminate historical lines of inquiry, or at least serves as a medium for the playing out of ideas, one which is off-limits to non-readers, just as everyday signage is unavailable to foreign-language speakers. "I am quite in the dark: the feeling is akin to trying to read legal code or, sometimes, the IRS code. I feel like I ought to get it, but I don’t, and I won’t." Traditional wisdom might lead one to believe that "learning to read code" is monocultural task, a conservative dance which can only be danced one way. However, in the growing methodologies of Critical Code Studies, computer code may also be interpreted or approached through other means or perspectives. This line of code, while maintaining maximum brevity, manages to represent the fundamentals vital to interpreting a much broader class of codes. It acts as a gate into the worlds of external ideas embedded within computer codes.

Contents

[hide]

One Line

Unusually, this book focuses on a single line of code, a BASIC program with only two statements. Our understanding of cultural production, and of our culture overall, has been greatly advanced by studies that focus on a single work, such as Barthes’s S/Z, Beckett’s Proust, Arnheim’s Genesis of a Painting: Picasso’s Guernica, and Foucault’s Ceci n’est pas une pipe. These paintings and texts are significantly more complex than a one-line BASIC program, but the computer program is also more unusual and far less studied as a cultural artifact, so there is much more to explain regarding its context.

By analyzing this short program from multiple viewpoints, the book explains how to read code deeply and shows the insights that come from doing so. Instead of discussing software merely as an abstract formulation, this book focuses on a specific program that exists in different printed variants and executes on a particular platform. At the same time, the book considers how the program engages with the cultural imagination of the maze, the history of regular repetition and randomness in computing, the story of the BASIC programming language and the specific nature of the Commodore 64. The eponymous program is treated as a distinct cultural artifact, but it also serves as a grain of sand in which a world is visible, a Rosetta Stone that gives us important access to the phenomenon of creative computing and the way computer programs exist in culture.

Ten Authors

The other major unusual feature of this book is that, although the book is mostly written in a single voice, it is written collaboratively by ten authors. This method of authorship shares some features with that used to write Wikipedia, although it differs from the writing of that encyclopedia in some significant ways, too. Our book was not written in public and was not open to anyone's edits; we gathered as a group after expressing interest in this program specifically during an online Critical Code Studies Workshop and, in a few cases, after being invited due to our interest in and publications on the study of code. While Wikipedia eschews "original research" for writing about facts which can be cited, our book is composed of scholarship, critical arguments, and original ideas about this program. We have included only those arguments and ideas that we find to some extent compelling and that we all essentially agree with.

To produce a book-length discussion of 10 PRINT that situated the program in all of its relevant contexts and explained those contexts, it was clear that we would need to bring a rich variety of perspectives to bear. This book deals deeply with art history, the development of programming languages, the working of computation in general, the technical specifics of the Commodore 64 and related platforms, the material history of texts and the transmission of program in print, and many other topics. Given this range of related areas, it was sensible for us to share the background and fluency that we collectively have in these areas.

Instead of isolating ourselves and writing ten articles, which surely would have produced significant overlaps and left significant gaps, we chose to attempt a new type of writing and to write what should appear, to the reader, as a book by a single author. Where it was necessary to write individually about personal experiences or perspectives that other authors do not share, we have included short singed notes that appear alongside the main text.

10 PRINT CHR$(205.5+RND(1)); : GOTO 10

By way of introducing this program, here is an initial explication of what each of its tokens do and mean.

10

"10" is the only line number in this one-line program, and probably the most conventional line number to use for the first line of any BASIC program. Most of the programs in the Commodore 64 User's Guide start with line 10, a choice typical on other platforms as well. Numbering lines in increments of 10, rather than simply as 1, 2, 3, ..., allows for lines to be inserted more easily if the need arises during program development: the lines after the insertion point will not have to be renumbered.

The standard version of BASIC for the Commodore 64, BASIC version 2, made this sort of line numbering practice wise. There were some extensions to BASIC which provided a RENUMBER or RENUM command that would automatically redo the line numbering. This convenience had a downside: if the line numbers were spaced out in a meaningful way so that part of the work was done beginning at 100, another segment beginning at 200, and so on, that segmentation would be obliterated by the renumbering.

The variant of this program that appears in RUN uses 8 as its line number. This makes the program more concise in its textual representation, although it does not save any memory -- for each line of BASIC stored in RAM, two bytes are allocated for the line number, whether it is 1 or 63999 (the maximum value allowed). Of course, any single digit, including "1," could have been used instead. But for a program that loops forever, it is perhaps also appealing to have the one line numbered "8," an infinity sign turned on its side, a digit that suggests the potentially endless loop of the figure eight. Although "8" may offer us grist for interpretation, it is a departure from tradition and from standard line-numbering convention for a multi-line program. Mainly, the RUN program simply attests to the arbitrariness of the line number.

Why are line numbers needed at all in a BASIC program? The programs we write today in C, Perl, Python, Ruby, and other languages don't use line numbers. They aren't necessary in BASIC, as demonstrated by versions of BASIC including QBASIC and Visual Basic. If one wants the program to branch to a particular statement, a label can be attached to that statement. Where line numbers particularly help is in editing the program, particularly when using a line editor or without access to a scrolling full-screen editor. The Commodore 64 does allow limited screen editing in the standard BASIC interpreter: the arrow keys can be used to move the cursor to a line, the line can be edited, and pressing return saves the new version of the line. This is a better editing capability than comes standard on the Apple II, but there is still no scrollback in BASIC on the C64. Line numbers provide a convenient way to list a particular line or range of lines. Typing a line number by itself will delete that line, if one exists in memory. The interactive editing abilities that line numbers allow were well-represented even in early versions of BASIC, including the first version of the BASIC that worked with the Dartmouth Time Sharing System.

(SPACE)

The space between "10" and "PRINT" is optional, as are all of the spaces in this program. If a user enters "10PRINTCHR$(205.5+RND(1));:GOTO10" that line will function identically. The spaces are of course helpful to the person trying to type in this line of code correctly: they make it more legible and more understandable.

Even in this exceedingly short program, which has no variables (and thus no variable names) and no comments, the presence of these optional spaces indicates some concern for the people who will deal with this code. Spaces acknowledge that the code is not only something to be automatically translated to machine instructions, but is also something to be read, understood, and potentially modified and built upon by human programmers. The same acknowledgment is seen in the way the keywords are presented in their canonical form: "?" could be used instead of PRINT there are two-character abbreviations that allow the other keywords to be entered quickly. But, for clarity, the longer but easier-to-read version of these keywords is shown.

PRINT

This statement causes its argument to be displayed on the screen. The argument to PRINT can take a variety of forms, but here it is a string, like "HELLO WORLD" but generated by a function and only a single character long. This command is so well-known to us today that we may overlook that, as it is used here, it does not literally "print" anything. To send output to a printer, PRINT has to be followed by "#" and the appropriate device number, then a comma, and then the argument that is to be printed. By default, without a device number, the output goes to the screen - a television or composite video monitor.

However, when BASIC was first developed in 1964 at Dartmouth College, the physical interface was different. Remarkably, the language was designed for college students to use in interactive sessions; they would not have to submit batch jobs on punch cards as was common at the time. However, users worked not at screens but at print terminals, initially Teletypes. So a PRINT command that executed successfully did actually cause something to be printed. Although BASIC was less than 20 years old when a version of it was made for the Commodore 64, that version nevertheless has a residue of history, leftover terms from before a change in the standard output technology. Although video displays replaced scrolls of paper with printed output, the keyword PRINT remained.

The automatic scrolling behavior that PRINT accomplishes (shifting the text up when at the bottom of the screen by calling the KERNAL's CHROUT routine) points back to the print heritage of home computing. While the video display is 40 characters wide, the Commodore 64 maintains an 80-column line internally, which is why BASIC lines can be at most 80 characters. This 80-column logical line hearkens back to the 80-column line of the print terminal - which itself derives from the 80 columns on punched cards, which had been in use for decades before general-purpose computing.

CHR$

This function takes a numeric code and returns the corresponding character, which may be a digit, a letter, a punctuation mark, a space, or a "character graphic," a non-typographical tile typically displayed alongside others to create an image. The standard numerical representation of characters in the 1980s, still is wide use today, is ASCII, a 7-bit code that represents 128 characters. On the Commodore 64 and previous Commodore computers, this representation was extended, as it often was in different ways on different systems. In extensions to ASCII, the other 128 numbers that can be represented in 8 bits are used for character graphics and other symbols. The Commodore 64's character set, which had been used previously on the Commodore PET, was nicknamed PETSCII.

The complement to CHR$ is the function ASC, which takes a quoted character and returns the corresponding numeric value. A user who is curious about the numeric value of a particular character, such as the capital letter A, can type PRINT ASC("A") and see the result, 65. A program can also use ASC to convert a character to a numeric representation, perform arithmetic on the number that results, and then convert the new number back to a character using CHR$. In lowercase mode, this can be used to shift character between uppercase and lowercase. Or this sort of manipulation might be used to implement a substitution cipher, for instance.

Character graphics exist as special tiles that are more graphical than typographical. That is, they are mainly intended to be assembled into larger graphical images rather than typeset along letters, digits, and punctuation. But these tiles are placed in a typographical framework: A textual system, built on top of a bitmapped graphic display, is being reused for graphical purposes. This is a typical way in which a system, adapted for a new, particular purpose, is retrofitted to do something else.

(

CHR$ and RND are both functions, so the keyword is followed in both cases by an argument in parentheses. CHR$ is a string function (it takes a numeric argument and returns a string) while RND is an arithmetic function (it takes a numeric argument and returns a number). The parentheses make it clear that, for instance, "RND(1-2)" is the same as "RND(-1)," while "RND(1)-2" is two subtracted from the result of "RND(1)".

205.5

When converted into an integer, this value is truncated (rounded down) and becomes 205; if more than .5 and less than 1 is added to it, the integer result will be 206. This means the character printed will either be the one corresponding to 205 or the one corresponding to 206: A left-leaning or right-leaning diagonal line. A quirk of the Commodore 64 character set is that these two characters, and a run of several character graphics, have two numeric representations. Characters 109 and 110 duplicate 205 and 206, meaning that a program that has 109.5 instead of 205.5 will produce identical output.

+

"+" here indicates addition, of course, but it's less obvious that this is the addition of two floating point numbers with a floating point result. The first of these is 205.5; the second is whatever value that RND returns, a value guaranteed to be between 0 and 1. There is no way to do integer addition in Commodore 64 BASIC: "+" always means floating-point addition. If an integer is provided as an argument, it is converted to a floating point number before the addition is done. The result is floating point number, although such a result is displayed without a decimal point or any digits to the right if those are all zero. This means that figuring out "2 + 2" is a much slower computation that it needs to be, but it also means that an easy-to-apply, one-size-fits all mathematical operation is provided for the programmer by BASIC. Whether the programmer wishes to add temperatures, prices, tomato soup cans, or anything else, "+" will work.

The origin of this mathematical symbol is, like "&," as an abbreviation for "and." As is still conventional on today's computers, the Commodore 64 has a special "plus" or addition key but does not have any way to type a multiplication sign or a division sign. While they appear in some 8-bit codes that extend ASCII and in Unicode, the multiplication and division signs are absent from ASCII and from PETSCII. Instead, the asterisk (*) and the slash, virgule, or solidus (/), are used. Given the computer's development as a machine for the manipulation of numbers, it is curious that typographical symbols have to be borrowed from their textual uses ("*" indicating a footnote, "/" a line break or a juxtaposition of terms) and pressed into service as mathematical symbols. Perhaps it can lead us to question the idea that the computer is essentially numeric rather than as textual or as graphical a device as it is a numerical one.

RND

To a first approximation, this function returns a random number, one which is between 0 and 1. The number returned is, more precisely, pseudorandom: while the sequence of numbers generated has no discernible pattern and is hard to predict, it is actually the same sequence each time. This is not a failing; the consistent output allows for debugging. More can be said about randomness, and much more is in chapter [???]. It is convenient that the number is always between 0 and 1; this allows it to easily be multiplied by another value and scaled to a different range. If one wishes to pick between two options at random, however, one can also test the random value to see if it is greater than .5. Or, as is done in this program, one can add 205.5 and convert to an integer so that 205 is produced with probability .5 and 206 with probability .5.

1

When RND is given any positive value as an argument, it produces a number using the current seed. This means that when RND(1) is invoked immediately after startup, or before any other invocation of RND, it will always produce the same result: .185564016. The next invocation will also be the same, no matter what the time or which Commodore 64 is used, and the next. Since the sequence is deterministic, the pattern produced by the 10 PRINT ... program, when run before any other invocation of RND, is always the same.

;

Using a semicolon after a string in a PRINT statement causes the next string to be printed immediately after the previous one, without a newline or any spaces between them. The other options are the use of a comma, which moves to the next tab stop (10 spaces), or the use of no symbol at all, which causes a newline to be printed.

Although this use of the semicolon from PRINT formatting was not original to BASIC, the semicolon was introduced very early on at Dartmouth, in version 2, a minor update that had only one other change.

:

The colon separates two BASIC statements which could have been placed on different lines. In a program like this on the original Dartmouth version of BASIC, they would have to each be on their own line. To keep programs clear and uncluttered, there could be no multi-statement lines. The colon was introduced by Microsoft, the leading developer of microcomputer BASIC interpreters, to allow more code to be packed onto home computers.

GOTO

This is an unconditional branch to the line indicated - which is the program's only line, line 10. The GOTO keyword and line number functions like the JMP machine language instruction. In this case, it returns control to an earlier point, causing the first statement to be executed endlessly - or at least until the program is somehow interrupted, either by the user pressing the STOP key or by the power being shut off.

Plan of the Book

Works Cited

http://www.rarityguide.com/articles/articles/31/1/Academy-BASIC-110---The-Missing-President/Page1.html

Personal tools