SNAP (programming language)
SNAP, short for Stylized, Natural, Procedural, is an educational programming language designed by Michael Barnett while working at RCA in 1968 and later used at Columbia University to teach programming in the humanities. It is an imperative programming language, like many languages of the 1960s, but was deliberately verbose, attempting to look more like conversational English in the fashion of HyperText and later languages. Unlike other educational languages of the era, SNAP was not intended to be interactive and was designed to be programmed via punch cards. To save cards, multiple period-separated statements could be written  on every card, so the resulting code often looked like a single paragraph. History. In 1964, Michael Barnett joined RCA's newly-formed Graphic Systems Division which had been formed to commercialize the photo-typesetting technology they had licensed from Rudolf Hell. Originally known as Digiset, RCA sold the systems under the name Videocomp. About 50 Videocomp systems were sold over its history. In 1964 and 1965, Barnett developed a page description language known as PAGE-1 to write programs that resulted in Videocomp output, similar to the way the later PostScript language produces pages on laser printers. One of the  early applications of this system was to publish "Social Sciences Index" by the H. W. Wilson Company. This led to Barnett's interest in the social sciences and his increasing interactions with H. W. Wilson and Columbia University's humanities department. Barnett took a position at H. W. Wilson in 1969. He had also started to teach courses on library automation at the Columbia School of Library Service, and in 1970, computer programming in the humanities. He joined the Columbia faculty full-time in 1975. The first version of SNAP was written by William Ruhsam of RCA in FORTRAN IV  for the RCA Spectra 70, although a version for the IBM 360 in OS-360 was also produced. some time in 1967 or 1968. The language generated a fair amount of comment, especially in the early 1970s, but appears to have had little direct influence on later languages. Description. General concepts. SNAP allowed multiple statements to be placed on a single line, and used the period as the statement separator. This produced code that looked like English sentences, and was generally organized into blocks that looked like paragraphs. SNAP did not use line numbers for editing, and instead used in-code  labels for branch targets, as was the case in FORTRAN. In SNAP, a label could be placed anywhere in the code by surrounding the textual name in parenthesis like . Labels were not separate statements, and did not require a period after them. Variables names could contain spaces, which is relatively rare for programming languages even today. Variables could hold strings or numbers, but different syntax was used to assign each one. For numbers, a simple syntax was used, was also used to perform mathematical operations, like A simpler syntax was offered for the more common increment and decrement operations, or  For strings, a longer syntax was typically used, Substrings were accessed using a HyperTalk-like syntax by referring to the ordinal position, for instance, , or SNAP also offered array-like collections known as "lists". Internally, these were stored as comma-delimited strings. Most of the string-related commands could be used to work with these by adding to the end. For instance, one could read a series of cards using , which would read each card as a separate string into the CARD variable. Items within a list were accessed using the same ordinal syntax, for instance , or Lists of numbers  could be created using String variables can also be used as lists, or arrays. This was accomplished using the same ordinal position syntax but referring to the variable name and not the . For instance, would create an array called PART with two strings in it. An important point of the SNAP system is that the statement is not static; it does not define KEY as the character at location J when it is encountered in the code, but when any following code accesses KEY. For instance, would result in two different strings being printed. In this fashion, has more in  common with the BASIC programming language's user-defined functions than it does with the statement, which is static. A static copy of a string could be made by Other string functions included codice_1, codice_2, codice_3 and codice_4 Unconditional branches were called using , for instance, There was also the alternative form . There was no difference between them, although the context of the surrounding code generally meant one form or the other was more natural to read. One could also refer to the start of the program with "As follows" could be used to refer to the next statement, , which could  be used to clarify branches. Conditional branches used an if–then(–else) structure: As in most languages, the section was optional. Note the use of to make a compound statement within the then section, offering a block structure. For string comparisons, one used or the optional . SNAP included a number of other keywords that had no behaviour of their own that were added simply for syntactic sugar. Among them were , , which the programmer could add in many locations to make the syntax more readable. Typical uses included and . Statements. From "A Natural Language". Variables and expressions are in "italic". Optional forms  are separated by vertical bars, |. Braces surround optional items, while angle-brackets surround required items that have more than one form. "value" refers to a numeric constant or variable, "string" to a quote-delimited string constant or string variable. Flow control: Mathematics: String manipulation: Input/output related: Others: Example. Here is the largest example of a practical program given in "SNAP", which reads strings from cards and then prints out the individual words found in them: For clarity, the following version simply spaces out the statements onto separate lines and adds appropriate whitespace: The program s a single card  and assigns the string data found on it to the variable named . It then sets up two pointers, and . A function called is ed that returns the Jth character of . It then examines the Jth character to see if it is a word-breaking character or off the end of the string. If neither of these are true, it moves to the next character and tries again. This loop continues until it finds a word-breaking character or falls off the end of the card at the 80th character. If it has hit the end of the card, it jumps  to the . If it does find a word-breaking character, it jumps to , which backs up one character to skip the punctuation it just examined. It then naturally falls through to the . That code prints out the string between the starting position in to the current position in . If we have not reached the end of the card, move forward by two characters to skip over the punctuation we previously avoided and move the pointer to the start of the next (potential) word. Then set to to position our next word's starting position from this point, and return to  . If we are at the end of the card, start the entire program over and read another card.