scheme-faq-general


Scheme Frequently Asked Questions

The material on this page is licensed under the terms of the GNU Free Documentation License. See scheme-faq-license for more information about this.

general | language | macros | misc | programming | standards

General

Why is Scheme called Scheme?

According to Steele and Gabriel's "The Evolution of Lisp" paper, Scheme was originally called Schemer, in the tradition of the AI languages Planner and Conniver. But the ITS operating system had a 6-character limitation of file names, so the names were shortened to PLNR, CNVR, and SCHEME. [ Eventually the truncated name Scheme stuck.

What is the difference between Scheme and Common Lisp?

Scheme is a dialect of Lisp that stresses conceptual elegance and simplicity. It is much smaller than Common Lisp; the language specification is about 50 pages, compared to Common Lisp's 1300 page draft standard. Advocates of Scheme often find it amusing that the entire Scheme standard is shorter than the index to Guy Steele's "Common Lisp: the Language, 2nd Edition". Unlike the Scheme standard, the Common Lisp standard has a large library of utility functions, a standard object-oriented programming facility (CLOS), and a sophisticated condition handling system.

What is Scheme used for?

Scheme is often used in computer science curricula and programming language research, due to its ability to represent many programming abstractions with its simple primitives. It is also an ideal test bed for compilation and interpretation techniques since it is possible to write a simple, yet fully standards-compliant Scheme interpreter in just a few days.

There are few known uses of Scheme in "real-world" systems. Partially this may be due to the fact that Scheme is often well-hidden inside a system. Probably the most successful, and yet little-known use of Scheme is in the Document Style Semantics and Specification Language (DSSSL), which is an ISO standard for processing SGML documents. See http://www.oasis-open.org/cover/dsssl.html for details. Other examples of successful Scheme applications are

AL

The "Animation Language" provides an environment for procedural computer animation which provides a powerful modeling language, a language interpreter, and a set of interactive animation tools. See http://www.accad.ohio-state.edu/~smay/AL/.

BRL

The "Beautiful Report Language"; a framework for building server-side web applications. See http://sourceforge.net/projects/brl/.

Common Music

A music composition environment which produces sound by transforming a high-level representation of musical structure into a variety of control protocols for sound synthesis and display. See http://commonmusic.sourceforge.net/doc/cm.html.

Festival

A general multi-lingual speech synthesis system with a Scheme-based command interpreter. See http://www.cstr.ed.ac.uk/projects/festival/.

Gandalf

An Automated Theorem Proving System written in Scheme. See http://sise.ttu.ee/it/gandalf/.

GIMP

The GNU image manipulation program. See http://www.gimp.org/.

GnoTime

A time tracker application that uses Scheme for generating reports. See http://gttr.sourceforge.net.

GNUCash

A tool for managing personal finances. See http://www.gnucash.org/.

Guile

The GNU project's extension language framework. See http://www.gnu.org/software/guile/guile.html.

Impromptu

An OSX programming environment for composers, sound artists, VJ's and graphic artists with an interest in live or interactive programming. See http://impromptu.moso.com.au.

JACAL

An interactive symbolic mathematics program. See http://swissnet.ai.mit.edu/~jaffer/JACAL.html.

Kali

A Scheme for implementing distributed systems. See kali-scheme-revival.

LilyPond

Engraves sheet music. LilyPond is partially written in Scheme, and also uses Scheme as an extension language. See http://lilypond.org/web/index.

Metcast

A system for distributing weather information, written in Scheme. See http://www.metnet.navy.mil/Metcast/.

MilkyWay

Avant!'s, recently acquired by Synopsys, flagship VDSM database product features Scheme as the extension and tool command language. See http://synopsys.com.

Naughty Dog

The game developer Naughty Dog Inc have used Scheme in the development of a several of their games. See http://www.naughtydog.com/.

Sawfish

An extensible window manager using Scheme as the scripting/extension language. See http://sawmill.sourceforge.net/.

Scribe

A text processor for writing technical documents and producing output in a variety of formats. See http://www-sop.inria.fr/mimosa/fp/Scribe/.

Scsh

The Scheme shell; a Unix shell that uses Scheme as the scripting language. See http://www.scsh.net/.

Scwm

The Scheme Constraint Window Manager; an X11 window manager with a Scheme-based dynamic configuration language. See http://scwm.sourceforge.net/.

Siag Office

A free Office package for Unix that features Scheme as one of its extension languages. See http://siag.nu/index.shtml.

Snd

A sound editor that features Scheme as one of its extension languages. See http://ccrma-www.stanford.edu/software/snd/snd/snd.html.

TeXmacs

A free scientific text editor, which was both inspired by TeX and GNU Emacs. It uses Scheme as an extension language. See http://texmacs.org/.

Ximian Evolution

An award-winning personal and workgroup information management solution for Linux and UNIX-based systems that uses Scheme as the language for defining mail filtering rules. See http://www.ximian.com/products/evolution/.

Is Scheme slow/big?

The first question you have to ask yourself is "Does it really matter?". Development time and maintenance effort are often much more important than execution speed and memory resources - "Machine cycles are cheap, people cycles are not."[Tucker Withington]. Nevertheless, there are obviously still applications where performance matters, e.g. embedded systems. There are Scheme compilers which perform quite a lot of optimisation and either compile to C or directly to machine code. The performance of such code can be pretty close to C for some applications.

The compactness of the core Scheme language make it possible to write interpreters with a very small memory footprint - there are even implementations that run on a PalmPilot (see here). Some Scheme interpreters perform a significant amount of optimisation. There is some evidence to suggest that interpreted program execution, in combination with just-in-time compilation, can be faster than executing pre-compiled code because the interpreter / JIT-compiler can perform optimisations using information that is only available at run time. As of December 12, 2007, mzscheme says: "At run time on x86, x86_64, and PowerPC platforms, MzScheme converts byte code to native code through a just-in-time compiler", so there is at least one implementation that performs JIT.

The design of Scheme makes it quite hard to perform certain common types of optimisations. For instance, one cannot normally inline calls to primitives (such as + and car) because Scheme allows the re-binding of their names to different functions. Many optimising Scheme interpreters/compilers therefore include modes that impose some restrictions on the programmer in exchange for improved execution speed.

What is the best way to learn Scheme?

Scheme is an easy language to learn once you get over your fear of parentheses. The syntax of the language contains just a handful of constructs. Anyone familiar with other programming languages will be able to write "interesting" Scheme programs after just a couple of days. Scheme does contain some advanced concepts, such as continuations and hygienic macros, that are tricky to come to grips with for both novice programmers and professionals alike. Mastering these takes time but is well worth the effort - it will make you a better programmer not just in Scheme but any language.

You need to get hold of one of the many introductory text books. A pretty comprehensive list can be found at http://www.schemers.org/Documents/#intro-texts. Some of these books are also available online.

It is also essential that you install a Scheme implementation, so you can try out examples and generally explore the language by writing code in it. A fairly comprehensive list of Schemes can be found in here. Not all of them are suitable for beginners. You ought to pick one implementation that is well-documented, runs on your operating system of choice, is standards-compliant (see here) and has an interpreter and built-in debugger (see here).

You should also read (and re-read) the current Scheme standard. See here. It is a very short and to-the-point document. At the beginning, you won't understand most of it, but you can still get a general feel for language. As you progress, the standard becomes an invaluable reference document for checking whether a particular concept / construct is covered by the standard and how exactly it is supposed to work.

Is there an Emacs mode for Scheme?

Emacs comes with two Scheme modes. Most people prefer the one that is not the default. To switch to that mode, put something like this into your .emacs file:

 (autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t) 
 (autoload 'run-scheme "cmuscheme" "Switch to interactive Scheme buffer." t) 
 (setq scheme-program-name "name-of-your-scheme-program") 
 (add-hook 'scheme-mode-hook 'turn-on-font-lock) 

The major mode does syntax-highlighting and indentation. The minor mode, invoked with M-x run-scheme, executes a Scheme interpreter in an Emacs buffer. You can evaluate sections of a program in the buffer or type into it directly.

For more advanced syntax-highlighting and indenting, check out the various extensions to the cmuscheme mode at http://www.cs.indiana.edu/proglang/scheme/iucs.html.

MIT Scheme includes a specialized mode (mit-scheme.el) that understands some of MIT's extensions and provides a closer integration with the REPL.

Quack (http://www.neilvandyke.org/quack/) provides numerous enhancements to Emacs support, works with numerous Scheme implementations, and is a no-brainer install (unless you are using a rare Scheme implementation for which even better REPL integration exists).

Description of these, and some other Emacs packages, that provide support for Scheme, you can find in following article.

How can I "pretty-print" Scheme programs?

There are a number of tools available:

A2PS

The GNU "Any to PostScript" filter. It can produce PostScript for program listings in a variety of languages, including Scheme. See http://www.infres.enst.fr/~demaille/a2ps/.

Grind

A PostScript pretty-printer for Scheme. See http://www.cs.bgu.ac.il/~gmayer/grind/.

l2t

The "Literate Programming Utility",allows easy insertions of program source snippets into TeX documents and includes Scheme pretty-printing capabilities. See http://www-spi.lip6.fr/~queinnec/WWW/l2t.html.

SLaTeX

SLaTeX is a Scheme program that allows you to insert program code (or code fragments) directly in your LaTeX or plain TeX source. There is also an extension that supports writing SLaTeX documents available at mmm-slatex.el.

alltt

The alltt environment in LaTeX supports inserting fixed-width font fragments (i.e. code) into TeX documents. It is fairly plain -- a verbatim environment that understands more of LaTeX's symbols -- but fast and simple: just {{{\usepackage{alltt} }}} and {{{\begin{alltt} }}} ... {{{\end{alltt} }}}.

noweb

The noweb literate programming system allows LaTeX documents with multiple code fragments comprised of more than one language (in one document). It also provides tools to extract the executable(s) from the document.


category-scheme-faq