170 likes | 384 Views
The Scheme Programming Language. History and Significance Dmitry Nesvizhsky CIS24 Professor Danny Kopec. Scheme: History. Started as an experiment in programming language design by challenging some fundamental design assumptions
E N D
The Scheme Programming Language History and Significance Dmitry Nesvizhsky CIS24 Professor Danny Kopec
Scheme: History • Started as an experiment in programming language design by challenging some fundamental design assumptions • A dialect of the LISP Programming Language invented by Guy Lewis Steele Jr. and Gerald Jay Sussman
Scheme: History • Emerged from MIT in the mid-1970's • Originally called Schemer • Shortened to Scheme because of a 6 character limitation on file names • Designed to have very few regular constructs which compose well to support a variety of programming styles • Functional, object-oriented, and imperative
Significant Language Features • Supports lexical scoping, uniform evaluation rules, and uniform treatment of data types • Does not support the concept of a pointer, uninitialized variables, specialized looping constructs, or explicit storage management • All data type are equal • What one can do to one data type, one can do to all data types
Significant Language Features • There are seven kinds of expressions • Constant • Variable reference • Procedure creation • Procedure application • Conditional • Assignment • Sequence
Significant Language Features • Scheme also has the usual assortment of data types • Characters • Strings • Arrays • Lists • Numbers • Functions (also called procedures) • Boolean • Ports • Symbols
Significant Language Features • Numbers are especially interesting • An integer is a rational and a real is a complex • Scheme requires no looping constructs • Any function which calls itself in the "tail" position is just a loop
Significant Language Features • Scheme has several important advantages • 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
Significant Language Features • Scheme has several important advantages (continued) • Supports 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
Significant Language Features • Scheme has several important advantages (continued) • Its abstractive power makes it easy to separate system specific optimizations from reusable code • Its compos ability makes it easy to construct systems from well-tested components
Areas of Application • Scheme is currently gaining favor as a first programming language in universities and is used in industry by such companies as TI, HP, and Sun
Areas of Application • Here are a few statistics regarding the schools using Scheme: • 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
Sample Program 1 • This program prints the phrase "Hello World“ ; indigo@owlnet.rice.edu (Scott Ruthfield) (define hello-world (lambda () (begin (write ‘Hello-World) (newline) (hello-world))))
Sample Program 2 • Scheme is an imperative language that favors recursion over iteration • The basic data structure is the list • In Scheme, "car" returns the first element of a list and "cdr" returns the remaining elements of the list • There is no need for an "iterator class" or pointers, as in C++ • In this program cdr recursion is used as an iterator, moving from element to element in the list • The result from each recursive call becomes the input, or term, for the addition operator, there by eliminating the need for a temporary sum variable
Sample Program 2 (continued) ; List Sum ; This program was found in "An Introduction to ; Scheme" by Jerry Smith, Prentice Hall, 1988 (define (list-sum lst) (cond ((null? lst) 0) ((pair? (car lst)) (+(list-sum (car lst)) (list-sum (cdr lst)))) (else (+ (car lst) (list-sum (cdr lst))))))