This outline is also available in PDF.
Held: Wednesday, 30 August 2006
Today we begin your exploration of the Scheme programming language (and
of algorithm development) in earnest.
- Why use programming languages?
- Scheme basics.
- Scheme history.
- In this class, you will express your algrorithms in Scheme.
- Some people wonder why we need computer languages like Scheme, Pascal,
C, Java, and the ilk.
- In part, it's probably because the computer elite want to maintain
their sense of superiority over the masses.
- In greater part, it's because English and other
can be ambiguous. At the very least, they have many similar structures
that are interpreted very differently. Consider the classic pair of
- Time flies like an arrow.
- Fruit flies like a banana.
- Remember: Computers are sentient and malicious.
It often seems that they'll do their best to misinterpret whatever it
is you write.
- Scheme is generally used in an interactive environment:
You type syntactically valid expressions and Scheme returns
- Later this semester, we'll see how to use Scheme in different
- Scheme's syntax is fairly simple: Since almost everything in
Scheme involves the application of a function to some arguments,
- an open parenthesis;
- the name of the procedure;
- a space;
- the parameters to the procedure (separated by spaces); and
- a close parenthesis.
- For example,
(+ 2 3 4)
(expt 2 3)
- If you remember this basic syntactic structure, you'll rarely get
syntactic errors from Scheme.
+: Sum its parameters.
*: Compute the product of its parameters.
-: Subtract the second parameter from the first.
(sqrt val): Compute the square root of val.
(expt v p): Compute vp.
(abs v): Compute the absolute value of v.
(max v1 v2 ... vn): Determine the largest of the given values.
(min v1 v2 ... vn): Determine the smallest of the given values.
- Scheme is a variant of Lisp (the List processing language).
- Lisp is one of the oldest high-level programming languages in
- It's from about the time of the invention of Cobol and only a few
years after the invention of Fortran.
- John McCarthy (of MIT and then Stanford) designed Lisp to provide a
language for programming in artificial intelligence.
- At the time, many people believed that intelligence was grounded
in symbolic processing.
- Lisp added many things to languages of the day:
- Symbolic values
- Dynamic lists as built-in data structures
- Automatic memory managment for those built-in data structures
- Functions as values (we'll return to this in a few weeks)
- In later reflection, McCarthy indicated that some of these things
were just luck. For example, the
lambda that you'll
learn about soon was just a
hmmm ... that sounds interesting, I'll
put it in fluke.
- Scheme was designed in the early 1980's (or maybe late 1970's) as
a variant of Lisp more appropriate for teaching computer science
(and doing many other things; it's more elegant).
- Scheme has a slightly clearer semantics than Lisp (and a formal
semantics, which is important).
- Scheme adds some nifty features for advanced programmers.
- But, at least for 151, you're doing Lisp-like programming.
- Now that you have learned DrScheme and some background, it's time for the
Beginning Scheme lab.
- I hope to spend the last few minutes of class giving you a chance to reflect
on your first real experiences with Scheme.