Previous Table of Contents Next


Part II
Scheme

3  Scheme

Chapter 3
Scheme

by Brian Harvey

Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary. Scheme demonstrates that a very small number of rules for forming expressions, with no restrictions on how they are composed, suffice to form a practical and efficient programming language that is flexible enough to support most of the major programming paradigms in use today. (Kelsey, Clinger, & Rees, 1998)

That’s the first paragraph of the Revised5 Report on the Algorithmic Language Scheme, edited by Richard Kelsey, William Clinger, and Jonathan Rees.

Many programmers instinctively feel that the expressive power of a programming language must be related to the complexity of its notation. For example, the popular language C++ was designed to increase the power of its predecessor C by adding many new syntactic and semantic extensions. Students are often encouraged to learn C before C++, even if they have no desire to program in C, because C++ is too complicated to learn all at once. Languages for beginners, such as BASIC and Hypertalk, are designed by a drastic elimination of expressive power for the sake of simplicity.

Scheme breaks this perceived relationship; it is both extremely simple and extremely expressive. Thus, writing a Scheme interpreter in Scheme itself is commonly assigned in a freshman computer science course. Scheme is a good language in which to write an interpreter because it can conveniently manipulate both the text of a program and the procedures that carry out the program. It is a good source language to interpret because it has hardly any syntax, so many annoying details of conventional interpreters can be avoided. You’ll see later that Scheme, although it was not designed with object-oriented programming specifically in mind, allows for the easy implementation of classes, instances, methods, and so on, with no syntactic extensions required.

3.1. Who Uses Scheme?

Most current, real-world programming is done in relatively low-level languages such as C++. But Scheme seems to meet the needs of a remarkably diverse community of users.

Computer science educators have been interested in Scheme as an instructional language since the 1984 publication of Structure and Interpretation of Computer Programs (Abelson, Sussman, & Sussman, 1996). This remarkable text set a new standard for the intellectual depth of introductory computer science courses. In the traditional first course, most of a semester is spent on the syntax and specific features of a programming language. Because Scheme has an extremely simple, uniform syntax, and because the procedure call mechanism is used for most of the purposes served by ad hoc constructions in other languages, the language itself takes only a week or two of instruction. The balance of the course can be spent on ideas such as functional programming, object-oriented programming, declarative program-ming, data-directed programming, synchronization, and compiler writing. Since 1984, several other Scheme-based textbooks have been published in the same intellectual tradition.

Programming language researchers develop Scheme compilers and runtime systems because instead of having to implement a large number of time-consuming but well understood features, they can focus on research issues in the implementation of high-level languages, such as automatic storage management and type inference.

Extensible programs have long used various dialects of Lisp as the extension language; the most famous example is the extensible text editor Emacs. The goals in an extensible program are to provide a user interface that nonprogrammers can use and also allow users who are programmers to extend the capabilities of the program. Some extensible programs use ad hoc extension languages that exist only in a single program, such as the Hypertalk extension language in the Hypercard program. But designing a good language is hard, and ad hoc languages often turn out to be awkward to use. A better choice is to use a language whose design has been perfected over years of general purpose use. Scheme is a good choice for an extension language because its simplicity means that the Scheme interpreter does not add too much to the size and complexity of the overall program. The Free Software Foundation has established Guile, a version of Scheme, as its extension language for all new software.

3.2. Scheme as a Dialect of Lisp

Some of Scheme’s expressive power comes from characteristics that it shares with every dialect of Lisp. I start with a brief review of these aspects of the language.


Previous Table of Contents Next