Scheme started as an experiment in programming …



Scheme started as an experiment in programming language design by challenging some fundamental design assumptions. It emerged from MIT in mid-1970s. (Sebesta, 2003) It is a dialect of the Lisp Programming Language invented by Guy Lewis Steele Jr. and Gerald Jay Sussman. Originally called Schemer, it was shortened to Scheme because of a 6-character limitation on file names.[1] Scheme is a small, exceptionally clean language that is fun to use. The language was designed to have very few, regular constructs which compose well to support a variety of programming styles including functional, object-oriented, and imperative.

Scheme is a general-purpose computer programming language. It is a high-level language, supporting operations on structured data such as strings, lists, and vectors, as well as operations on more traditional data such as numbers and characters. While Scheme is often identified with symbolic applications, its rich set of data types and flexible control structures make it a truly versatile language. Scheme has been employed to write text editors, optimize compilers, operating systems, graphics packages, expert systems, numerical applications, financial analysis packages, virtual reality systems, and practically every other type of application imaginable. (Louden, 2003) For these and other purposes, such companies as HP and Sun have employed it. Scheme is a fairly simple language to learn, since it is based on a handful of syntactic forms and semantic concepts and since the interactive nature of most implementations encourages experimentation. Scheme is a challenging language to understand fully, however; developing the ability to use its full potential requires careful study and practice.[2]

The Scheme Programming Language has lexical scoping, uniform evaluation rules, and uniform treatment of data types. Scheme does not have the concept of a pointer, uninitialized variables, specialized looping constructs, or explicit storage management. (Sebesta, 2003) In Scheme, all data types are equal. What one can do to one data type, one can do to all data types. There are seven kinds of expressions: Constant, Variable reference, Procedure creation, Procedure application, Conditional, Assignment, and Sequence. Scheme also has the usual assortment of data types: Characters, Strings, Arrays, Lists, Numbers, Functions (also called procedures), Boolean, Ports, and Symbols. Numbers are especially interesting in that an integer is a rational and a real is a complex. Scheme requires no looping constructs. Any function that calls itself in the “tail” position is just a loop. Scheme has several important positives. It is elegantly simple in that regular structure and trivial syntax avoids "special case" confusion. Its expressiveness means that one spends little time trying to work around the language – it lets users concentrate on what they want to say rather than on how to say it. Its support of a variety of styles (including object-oriented) allows users to better match their solution style to the style of the problems to be solved. Its formal underpinnings make reasoning about programs much easier. Its abstractive power makes it easy to separate system specific optimizations from reusable code. Its composability makes it easy to construct systems from well-tested components.[3]

Scheme programs are highly portable across implementations of the same Scheme system on different machines, because machine dependencies are almost completely hidden from the programmer.[4] Also, because of two related Scheme standardization efforts, it is possible to write programs that are portable across different Scheme implementations.

As stated earlier, Scheme supports many types of data values, or objects, including characters, strings, symbols, lists or vectors of objects, and a full set of numeric data types, including complex, real, and arbitrary-precision rational numbers. The storage required to hold the contents of an object is dynamically allocated as necessary and retained until no longer needed, then automatically deallocated, typically by a garbage collector that periodically recovers the storage used by inaccessible objects. Simple atomic values, such as small integers, characters, booleans, and the empty list, are typically represented as immediate values and thus acquire no allocation or deallocation overhead.[5]

Scheme was one of the first programming languages to incorporate first class procedures as in the lambda calculus, thereby proving the usefulness of static scope rules and block structure in a dynamically typed language. Scheme was the first major dialect of Lisp to distinguish procedures from lambda expressions and symbols, to use a single lexical environment for all variables, and to evaluate the operator position of a procedure call in the same way as an operand position. (Louden, 2003) By relying entirely on procedure calls to express iteration, Scheme emphasized the fact that tail-recursive procedure calls are essentially goto's that pass arguments. Scheme was the first widely used programming language to embrace first class escape procedures, from which all previously known sequential control structures can be synthesized. More recently, building upon the design of generic arithmetic in Common Lisp, Scheme introduced the concept of exact and inexact numbers. Scheme is also the first programming language to support hygienic macros, which permit the syntax of a block-structured language to be extended reliably.[6]

The Scheme Programming Language is being taught at many of the Universities in the United States as well as overseas. Below is the most up-to-date compilation of colleges, universities, and secondary schools that are using Scheme in their curricula.

Here are a few statistics regarding the schools using Scheme[7]:

• 286 colleges/universities worldwide - 108 of these use Scheme in introductory courses

• 159 colleges/universities USA only - 49 of these use Scheme in introductory courses

• 73 secondary schools worldwide

• 64 secondary schools USA only

Below are three sample programs written in Scheme:

1. This program prints the phrase "Hello World".[8]

(define hello-world

(lambda ()

(begin

(write ‘Hello-World)

(newline)

(hello-world))))

2. This program generates prime numbers.[9]

;

; primes

; By Ozan Yigit

;

(define (interval-list m n)

(if (> m n)

'()

(cons m (interval-list (+ 1 m) n))))

(define (sieve l)

(define (remove-multiples n l)

(if (null? l)

'()

(if (= (modulo (car l) n) 0) ; division test

(remove-multiples n (cdr l))

(cons (car l)

(remove-multiples n (cdr l))))))

(if (null? l)

'()

(cons (car l)

(sieve (remove-multiples (car l) (cdr l))))))

(define (primes ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download