I want to learn to write computer programs using the Scheme programming language. How do I begin?
By looking around to see which of the following tools you have available. It will be easier for you to learn Scheme if you have a text-editing program and an implementation of Scheme that can execute the programs that you write.
I have a text editor, but I've never learned how to use it. Is it really necessary, or even worth while, for me to learn the text editor before I start learning to program in Scheme?
It's worth while to learn how to start the text editor, how to enter and save text, how to revise text by deleting and inserting characters, and how to exit from the editor. Probably your text editor has many other features. If you need any of them, you can learn them later.
It's possible to learn a little bit of Scheme without using a text editor, but as the programs you write get larger and larger, you're going to find it increasingly difficult to type them in accurately. By using a text editor, you separate the job of typing your programs (and fixing typographical errors) from the process of having the computer execute them.
I have an implementation of Scheme. How do I use it? What do I do with it?
A Scheme program is a sequence of definitions and commands. A Scheme implementation reads in such a sequence, memorizes the definitions, and obeys the commands. However, the programmer can submit a program to Scheme in either of two ways:
When Scheme is running interactively, it begins by displaying a prompt -- some sequence of characters indicating that Scheme is ready to receive the first definition or command in the program. The programmer types it in, and Scheme processes it as soon as the programmer has finished typing it. Often the command directs Scheme to compute the value of some expression -- an arithmetic expression, for instance -- and in this case Scheme will print out the computed value. After processing the definition or command, Scheme displays another prompt, and the programmer types in the next definition or command, and so on.
When Scheme is running in batch mode, the programmer creates a file containing the entire Scheme program and gives Scheme the name of that file. Scheme then processes all of the definitions and commands in the program in succession. In batch mode, Scheme does not write out any prompts or display the result of each command; the program itself must explicitly perform any output that is desired.
You'll need to find out how to do three things with your implementation of Scheme:
To give you a general idea, here's how one does these three things in the implementation of Scheme that I use most often:
scm -p1 on the command
line.
(exit) after
Scheme's prompt.
frogs.scm, type scm -b frogs.scm on the command
line.
Why do Scheme implementations have both interactive and batch modes? What are the advantages of each one?
Batch mode is for finished programs. Its main advantages are that programs run faster and that the language interface is invisible (or, anyway, less visible) to the user of the program. The interactive mode is for programs that are under development; its main advantage is that the programmer gets useful feedback during her interaction with Scheme and can write a large program incrementally, writing, testing, and correcting one piece at a time.
What text editor do you and your students at Grinnell College use? What implementation of Scheme do you use?
We generally use the Emacs text editor and the SCM, Elk, or Scheme 48 implementation of Scheme. When you're just starting out, though, the differences among text editors or Scheme implementations are unimportant. Later on, you'll be in a better position to choose a working environment for serious programming.
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/scheme-web/getting-started.html