String-Oriented Symbolic Languages (SNOBOL)

FIELDS OF STUDY

Programming Language; Coding Techniques; Programming Methodologies

ABSTRACT

String-oriented symbolic language (SNOBOL) refers to a family of programming languages developed in the 1960s by computer scientists working at Bell Laboratories. The final and most common version was SNOBOL4. Several later languages were developed as successors, and some of the language's unique aspects remain influential. As its name implies, SNOBOL was created for manipulation of symbolic string data. This allows programmers to easily search, change, and utilize string variables in just a few lines of code. SNOBOL and derivative languages are well-suited to pattern-matching tasks.

PRINCIPAL TERMS

SNOBOL PROGRAMMING

The Bell Labs team designed the syntax and labels in SNOBOL to mimic speech, making it understandable even for beginning programmers. The language uses logic, operators, arrays, and standard loops. SNOBOL is dynamically typed, meaning that the programmer does not need to declare the type of variable being used. All variables are global, and SNOBOL programs often contain goto statements, which are common in older languages and machine languages. This linear way of programming stands in contrast to object-oriented languages that manipulate larger chunks of code called “objects.”

SNOBOL DATA TYPES

SNOBOL was designed to manipulate strings and match patterns. Since it was initially intended for use only at Bell Labs, the developers built only the features they needed into the original SNOBOL language. There was only one data type, no functions, and hardly any error control. As other programmers began expressing interest in a string-oriented language, the team added more features. SNOBOL2 was not widely released but added the ability to use functions. SNOBOL3 added the ability to create user-defined functions and became relatively popular. At that time, SNOBOL3 was only written for the IBM 7090 computer, which limited its use. Several programmers attempted to write equivalent versions for other computers, but these often contained bugs. SNOBOL4 fixed this compatibility problem by allowing itself to be run on a virtual machine, which could be used on many different computers. SNOBOL4 could also use arrays, tables, stacks, and other common features and data types.

Even with these additions, SNOBOL's main strength is its ability to powerfully manipulate strings. Of the various forms of string manipulation, SNOBOL relies on an approach called “pattern matching.” Pattern matching is fast, versatile, and relatively easy to understand. Because SNOBOL makes it so easy to work with strings, it gained widespread usage among researchers in the humanities and other text-heavy fields. However, the language also has significant disadvantages. Its unique syntax and other properties can make it challenging to work with, particularly for programmers used to more common languages. It also lacks many of the control structures expected in programming languages, making it unsuited to many tasks.

STRING MANIPULATION EXAMPLE

Consider a string named Greeting equal to “hello hello hello world, this is Bob.” Perhaps a programmer wants to change each instance of “hello” to “goodbye.” In SNOBOL, this conversion could be achieved with the following line of code:

Greeting “hello” = “goodbye”

The string Greeting would now equal “goodbye goodbye goodbye world, this is Bob.” Such conversions are useful when editing a segment of text or when the programmer does not want a user-inputted phrase to contain a particular word or phrase. Other basic uses of SNOBOL include parsing strings, checking if a string contains a certain substring, and finding substrings based on the surrounding text.

SNOBOL syntax is somewhat different from many later languages. For example, an if-statement in many languages would appear something like the following:




String-Oriented Symbolic Languages (SNOBOL)

A SNOBOL coder would not have to keep this code segment together. Instead, goto statements are used to direct the computer where to go next. Common SNOBOL syntax includes a label, a subject, and a goto command, each of which is optional. Here is an if-statement in SNOBOL:




String-Oriented Symbolic Languages (SNOBOL)

MODERN USAGE

The final official version of SNOBOL, SNOBOL4, was released in 1967. It enjoyed popularity into the 1980s, when object-oriented languages like Perl became favored for manipulating strings using regular expressions. In contrast with pattern matching, regular expressions use a collection of string-searching algorithms to find patterns within text. As object-oriented languages added more features, they became the preferred way to handle strings in all but a few specific cases.

Over the years, there have been attempts to revive SNOBOL. Original SNOBOL developer Ralph Griswold created a similar language called Icon in the late 1970s. It never enjoyed SNOBOL's widespread usage because it was too specialized. It did, however, receive attention from specialists for compilers, natural language recognition, and grammar analysis. Griswold also developed SL5, another language focused heavily on string processing. Decades later, SNOBOL and Icon served as inspirations for an object-oriented language called Unicon.

SNOBOL was a pioneer in the area of string manipulation and served as a template for other programming languages. Knowing the history of SNOBOL can give programmers a broader perspective on features of more modern programming languages.

—Joshua Miller and Daniel Showalter, PhD

Farber, David J., et al. “SNOBOL, A String Manipulation Language.” Journal of the ACM, vol. 11, no. 1, Jan. 1964, pp. 21–30, doi:10.1145/321203.321207.

Griswold, Ralph, and Madge T. Griswold. The Icon Programming Language. 3rd. ed., Peer-to-Peer Communications, 2002.

Jeffery, Clinton, et al. “Integrating Regular Expressions and SNOBOL Patterns into String Scanning: A Unifying Approach.” Proceedings of the 31st Annual ACM Symposium on Applied Computing, 2016, pp. 1974–79, doi:10.1145/2851613.2851752.

Jeffery, Clinton, et al. “Pattern Matching in Unicon.” Unicon Project, 16 Jan. 2017, unicon.org/utr/utr18.pdf . Accessed 4 May. 2017.

Koenig, Andrew. “The Snocone Programming Language.” Snobol4, www.snobol4.com/report.htm . Accessed 4 May 2017.

Paine, Jocelyn. “Programs that Transform Their Own Source Code; or: the Snobol Foot Joke.” Dr. Dobb's, UBM, 17 Jan. 2010, www.drdobbs.com/architecture-and-design/programs-that-transform-their-own-source/228701469 . Accessed 4 May 2017.