Paradigm | Imperative |
---|---|
Designed by | Michael Barnett, William Ruhsam |
First appeared | 1970 |
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.
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. [1]
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. [2] One of the early applications of this system was to publish Social Sciences Index by the H. W. Wilson Company. [3]
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. [4] He joined the Columbia faculty full-time in 1975.
The first version of SNAP was written by William Ruhsam of RCA in FORTRAN IV [5] for the RCA Spectra 70, although a version for the IBM 360 in OS-360 was also produced. [lower-alpha 1] some time in 1967 or 1968. [6] [lower-alpha 2] The language generated a fair amount of comment, especially in the early 1970s, [7] but appears to have had little direct influence on later languages.
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. [8]
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 parentheses like (FIRST LABEL)
. Labels were not separate statements, and did not require a period after them. [9]
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, SETITO1.
SET
was also used to perform mathematical operations, like SETITOTHEPRODUCTOF10 ANDJ.
A simpler syntax was offered for the more common increment and decrement operations, INCREASE M BY 1.
or DECREASE M BY 2.
[9]
For strings, a longer syntax was typically used, CALL "THIS IS A STRING" THE NEWSTRING.
Substrings were accessed using a HyperTalk-like syntax by referring to the ordinal position, for instance, CALLTHEJ-THCHARACTEROFNEWSTRINGTHENEWCHAR.
, or CALLTHEM-THTHROUGHN-THCHARACTERSOFTHEINPUTTHEOUTPUT.
[9]
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 THE ... LIST.
to the end. For instance, one could read a series of cards using READTHECARDLIST.
, 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 PRINTTHE5-THCARD
, or COPY "NEW STRING"ANDCALLITTHE7-THCARD.
Lists of numbers could be created using SETTHENUMBERLISTTO1,2,3,4,5.
[10]
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 CHARACTER
. For instance, CALL "HELLO"THE1-STPART.CALL "WORLD"THE2-NDPART.
would create an array called PART with two strings in it. [9]
An important point of the SNAP system is that the CALL
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, SETJTO1.PRINTKEY.INCREASEJBY1.PRINTKEY.
would result in two different strings being printed. In this fashion, CALL
has more in common with the BASIC programming language's DEF FN
user-defined functions than it does with the SET
statement, which is static. [11]
A static copy of a string could be made by COPYOLDSTRING,ANDCALLITNEWSTRING.
Other string functions included APPEND one string TO another string.
, OVERWRITE string-expression ON THE M-TH [AND SUBSEQUENT] CHARACTER[S] OF string-name.
, DELETE THE M-TH [THROUGH N-TH] CHARACTER[S] OF string-name.
and INSERT string-expression (BEFORE|AFTER) THE M-TH CHARACTER OF string-name.
[12]
Unconditional branches were called using CONTINUE
, for instance, CONTINUEWITHTHEFIRSTLABEL.
There was also the alternative form REPEAT THE FIRST LABEL.
. 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 CONTINUEFROMTHEBEGINNING.
"As follows" could be used to refer to the next statement, CONTINUEASFOLLOWS.
, which could be used to clarify branches. [13]
Conditional branches used an if–then(–else) structure:
IFJISLESSTHAN80 INCREASEJBY1,ANDREPEATFROMTHEFIRSTLABEL,OTHERWISECONTINUEASFOLLOWS.
As in most languages, the OTHERWISE
section was optional. Note the use of AND
to make a compound statement within the then section, offering a block structure. For string comparisons, one used IS
or the optional ISTHESAMEAS
. [12]
SNAP included a number of other keywords that had no behaviour of their own that were added simply for syntactic sugar. Among them were THE
, A
, FROM
which the programmer could add in many locations to make the syntax more readable. Typical uses included READARECORD
and REPEATFROMTHELOOPSTART
. [13]
From A Natural Language. [6] 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:
(string constant)
<CONTINUE|REPEAT> [WITH|FROM] <label|THE BEGINNING [OF THE PROCEDURE]|THE NEXT SENTENCE|AS FOLLOWS>
IF value|string <IS|ARE> [THE SAME AS] value|stringexpression[,AND expression...] [, OTHERWISE expression[,AND expression...]]
IS THE value[-TH] AND [SUBSEQUENT|PRECEDENT] CHARACTERS OF string
EQUAL TO
, LESS THAN
, GREATER THAN
, UNEQUAL TO
, GREATER THAN OR EQUAL TO
, LESS THAN OR EQUAL TO
IF THE INPUT IS EXHAUSTED
.TERMINATE
EXECUTE
Mathematics:
SET numeric variable TO value
- assigns a value to a numeric variableSET numeric variable TO THE [SUM|DIFFERENCE|PRODUCT|QUOTIENT|REMAINDER|CEILING|GREATER|LESSER] OF value AND value
INCREASE variable BY value
- simplified notation for additionDECREASE variable BY value
- ...and subtractionString manipulation:
CALL string [THE] string variable
- create a string function[FORM A] COPY [OF] string AND CALL IT [THE] string variable
- copy a string from one variable to anotherAPPEND string TO string variable
- append a string variable with another stringLINK string TO string
- appends the first string to the second, but does not copy it, future changes to the second string will be tracked as in a CALL
DELETE THE value[-TH] [THROUGH value [-TH]] CHARACTER[S] OF string variable
- trim a string from the selected character on, or a given rangeOVERWRITE string ON THE value[-TH] [AND SUBSEQUENT|PRECEDENT] CHARACTER[S] OF string variable
- replaces one character of a string with another, or that character and those running forward or backward from the selected position.Input/output related:
SELECT number [FOR <INPUT|OUTPUT>]
READ [A|THE] string variable
REQUEST [A|THE] string variable
FETCH [A|THE] string variable
SELECT
ed devicePRINT [A|THE] variable
TYPE [A|THE] variable
PUNCH [A|THE] variable
PERFORATE [A|THE] variable
WRITE [A|THE] variable
SELECT
ed deviceOthers:
CONTROL various
RESERVE SPACE FOR number <CHARACTERS IN variable|ELEMENTS IN [THE] variable LIST
DIM
statement in BASIC, sets aside a specified amount of memory to hold a string, or a given number of strings from a list. Using RESERVE
avoided memory operations as the string or list was built and improved performanceHere is the largest example of a practical program given in SNAP, [14] which reads strings from cards and then prints out the individual words found in them:
READARECORD.SETITO1.SETJTO1.CALLTHEJ-THCHARACTEROFTHERECORDTHEKEY.(LOOPSTART)IFTHEKEYIS " "CONTINUEWITHTHEBACKUP.IFTHEKEYIS ""CONTINUEWITHTHEBACKUP.IFTHEKEYIS "."CONTINUEWITHTHEBACKUP.IFJISLESSTHAN80 INCREASEJBY1,ANDREPEATFROMTHELOOPSTART,OTHERWISECONTINUEWITHTHEOUTPUTACTION.(BACKUP)DECREASEJBY1.(OUTPUTACTION)PRINTTHEI-THTHROUGHJ-THCHARACTERSOFTHERECORD.IFJISLESSTHAN79 INCREASEJBY2,SETITOJ,ANDREPEATFROMTHELOOPSTART,OTHERWISEREPEATFROMTHEBEGINNING.EXECUTE
For clarity, the following version simply spaces out the statements onto separate lines and adds appropriate whitespace:
READARECORD.SETITO1.SETJTO1.CALLTHEJ-THCHARACTEROFTHERECORDTHEKEY.(LOOPSTART)IFTHEKEYIS " "CONTINUEWITHTHEBACKUP.IFTHEKEYIS ""CONTINUEWITHTHEBACKUP.IFTHEKEYIS "."CONTINUEWITHTHEBACKUP.IFJISLESSTHAN80 INCREASEJBY1,ANDREPEATFROMTHELOOPSTART,OTHERWISECONTINUEWITHTHEOUTPUTACTION.(BACKUP)DECREASEJBY1.(OUTPUTACTION)PRINTTHEI-THTHROUGHJ-THCHARACTERSOFTHERECORD.IFJISLESSTHAN79 INCREASEJBY2,SETITOJ,ANDREPEATFROMTHELOOPSTART,OTHERWISEREPEATFROMTHEBEGINNING.EXECUTE
The program READ
s a single card and assigns the string data found on it to the variable named RECORD
. It then sets up two pointers, I
and J
. A function called KEY
is CALL
ed that returns the Jth character of RECORD
.
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 OUTPUT ACTION
.
If it does find a word-breaking character, it jumps to BACKUP
, which backs up one character to skip the punctuation it just examined. It then naturally falls through to the OUTPUT ACTION
. That code prints out the string between the starting position in I
to the current position in J
.
If we have not reached the end of the card, move J
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 I
to J
to position our next word's starting position from this point, and return to LOOP START
. If we are at the end of the card, start the entire program over and read another card.
AWK is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.
Icon is a very high-level programming language based on the concept of "goal-directed execution" in which code returns a "success" along with valid values, or a "failure", indicating that there is no valid data to return. The success and failure of a given block of code is used to direct further processing, whereas conventional languages would typically use boolean logic written by the programmer to achieve the same ends. Because the logic for basic control structures is often implicit in Icon, common tasks can be completed with less explicit code.
In computer science, control flow is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language.
HyperTalk is a discontinued high-level, procedural programming language created in 1987 by Dan Winkler and used in conjunction with Apple Computer's HyperCard hypermedia program by Bill Atkinson. Because the main target audience of HyperTalk was beginning programmers, HyperTalk programmers were usually called "authors" and the process of writing programs was known as "scripting". HyperTalk scripts resembled written English and used a logical structure similar to that of the Pascal programming language.
The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.
The syntax of the C programming language is the set of rules governing writing of software in C. It is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. C was the first widely successful high-level language for portable operating-system development.
In computer science, a for-loop or for loop is a control flow statement for specifying iteration. Specifically, a for-loop functions by running a section of code repeatedly until a certain condition has been satisfied.
SAIL, the Stanford Artificial Intelligence Language, was developed by Dan Swinehart and Bob Sproull of the Stanford AI Lab. It was originally a large ALGOL 60-like language for the PDP-10 and DECSYSTEM-20. The language combined the earlier PDP-6/-10 language GOGOL compiler, essentially an integer-only version of ALGOL, with the associative store from the LEAP language. The first release was in November 1969 and it saw continued development into the 1980s, including a commercial derivative, MAINSAIL.
TI-BASIC is the official name of a BASIC-like language built into Texas Instruments' graphing calculators. TI-BASIC is a language family of three different and incompatible versions, released on different products:
In computer programming, a statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. A program written in such a language is formed by a sequence of one or more statements. A statement may have internal components.
The syntax of Java is the set of rules defining how a Java program is written and interpreted.
Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.
In programming languages, a label is a sequence of characters that identifies a location within source code. In most languages, labels take the form of an identifier, often followed by a punctuation character. In many high-level languages, the purpose of a label is to act as the destination of a GOTO
statement. In assembly language, labels can be used anywhere an address can. Also in Pascal and its derived variations. Some languages, such as Fortran and BASIC, support numeric labels. Labels are also used to identify an entry point into a compiled sequence of statements.
The structure of the Perl programming language encompasses both the syntactical rules of the language and the general ways in which programs are organized. Perl's design philosophy is expressed in the commonly cited motto "there's more than one way to do it". As a multi-paradigm, dynamically typed language, Perl allows a great degree of flexibility in program design. Perl also encourages modularization; this has been attributed to the component-based design structure of its Unix roots, and is responsible for the size of the CPAN archive, a community-maintained repository of more than 100,000 modules.
PL/SQL is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database, TimesTen in-memory database, and IBM Db2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.
TI-BASIC 83,TI-BASIC Z80 or simply TI-BASIC, is the built-in programming language for the Texas Instruments programmable calculators in the TI-83 series. Calculators that implement TI-BASIC have a built in editor for writing programs. While the considerably faster Z80 assembly language is supported for the calculators, TI-BASIC's in-calculator editor and more user friendly syntax make it easier to use. TI-BASIC is interpreted.
Data General Extended BASIC, also widely known as Nova Extended BASIC, was a BASIC programming language interpreter for the Data General Nova series minicomputers. It was based on the seminal Dartmouth BASIC, including the Fifth Edition's string variables and powerful MAT
commands for matrix manipulation. In contrast to the compile-and-go Dartmouth BASIC, Extended BASIC was an interpreter.
SDS BASIC, also known as CP-V BASIC, Batch BASIC or Sigma BASIC depending on the version, is a BASIC programming language compiler for Scientific Data Systems's (SDS) Sigma series mainframe computers, originally released in 1967. Xerox purchased SDS in 1969 and began rebranding it as Xerox Data Systems, and finally just Xerox, at which time the language became known as Xerox BASIC.
The Hack Computer is a theoretical computer design created by Noam Nisan and Shimon Schocken and described in their book, The Elements of Computing Systems: Building a Modern Computer from First Principles. In using the term “modern”, the authors refer to a digital, binary machine that is patterned according to the von Neumann architecture model.
Acorn System BASIC and Atom BASIC are two closely related dialects of the BASIC programming language developed by Acorn Computers for their early microcomputers like the Acorn System 3 and Acorn Atom. Developed in-house, they have a number of significant idiosyncrasies compared to most BASIC dialects of the home computer era.