CSC 153 Grinnell College Spring, 2009
 
Computer Science Fundamentals
 

Getting Started

Abstract

This reading reviews some mechanics related to the use of the Mathematics/Computer Science Local-Area Network (the Campus Linux Network) for CSC 153. The lab also introduces the Scheme environment and introduces Scheme's read-eval-print loop.

More specifically, this lab discusses:

Since you have already programmed in some language on some computer system, some of these mechanics may already be familiar. However, at the very least, you should skim through the first several sections to be sure there are no surprises.

Please pay particular attention to the sections on Scheme and its history.


Logging In and Out

To use any of the computers in the Mathematics/Computer Science Local-Area Network (the Campus Linux Network), one must log in, giving a user name and a password. Contact the instructor if you have questions about this process.

Computers in the Campus Linux Network run the Debian Linux operating system, since this environment provides especially good support for activities related to computer science and mathematics. Debian Linux provides several user interfaces, programs through which one manages various programs and resources that the workstation can access. The recommended user interface is called GNOME. In most cases, GNOME will come up automatically when you log in.

To ensure that the system will use GNOME for your account,

Note: It is not necessary to turn off the workstation when you are finished. Workstations on the Campus Linux Network are designed to operate continuously; turning them off and on frequently actually shortens their life expectancy and significantly complicates the administration of this network.


Mozilla Firefox

Many materials for this course will be distributed over the World Wide Web rather than in paper copies. To view materials, such as this course's syllabus and this lab, you may follow these steps:

  1. Prepare to utilize the World Wide Web by clicking on the Firefox icon (the circular picture of the world at the bottom panel of the screen).

  2. The first time you run Mozilla FoxFire on the Campus Linux Network, two message boxes may pop up.
    1. One box asks you to consent to the terms of Firefox's licensing agreement;
    2. One box requests permission to create some configuration files in your home directory.
    You should approve both of these requests by clicking on the appropriate word. The pop-up boxes then disappear; you won't see them on subsequent uses of Mozilla Firefox.

  3. Initially, Firefox displays a World Wide Web document entitled "Zero-One," which is an entry point to Web site of the Department of Computer Science. (If for some reason your browser is set differently, use the URL http://www.cs.grinnell.edu/zero-one.xhtml to reach the desired starting page. In the left-hand column of this document, under the heading "Course front doors," you'll see the underlined listing "CSC 153: Computer Science Fundamentals (Mr. Walker)." Move the mouse to this listing and click the left mouse button. "Zero-One" is replaced with the document entitled "CSC 153: Computer Science Fundamentals."

Bookmarks

Because URLs are notoriously hard to remember and to type accurately, Firefox allows you to place a bookmark on any interesting or important document that you reach. To place a bookmark on the document currently displayed, move the mouse onto the word Bookmarks above the main display window, click the left mouse button to bring up the corresponding menu, and select the Bookmark This Page... operation. A new window, with the title "Add Bookmark" will appear. Move the mouse onto the button marked Add in the new window and click the left mouse button. You can subsequently return to that document by bringing up the Bookmarks menu again and selecting from it the title of the document.

For instance, I recommend that you bookmark the front-door page for this course, so that you can return to it easily, no matter what document is currently displayed.


The Terminal Window

Although you may be accustomed to a graphical user interface (GUI) from your past computer usage, you also need to become comfortable with a command-line interface. Historically, commands were typed into windows, and Unix/Linux provides several powerful tools for this type of interaction. To run various commands, you must invoke them by name. The computer program that reads and responds to such invocations is called the shell, and your interactions with the shell take place in a window generated by a program called a terminal emulator.

You may already have a terminal window on screen. If not, you can start one at any time by moving the pointer onto the small monitor icon on the bottom row of the front panel, and click with the left mouse button. Shortly a window will appear, displaying the shell prompt — the name of the workstation on which the shell is running, followed by a percentage sign. This prompt indicates that the shell is ready to receive instructions.

You enter such instructions using the keyboard. Move the mouse pointer into the terminal window to make it active. (You many need to click on the window, once your mouse is in the desired area.) The window frame changes color, indicating that the window has become active.

To shut down terminal, press <Ctrl/d> — that is, hold down either of the keys marked <Ctrl>, just below the <Shift> keys, and simultaneously press the <d> key. (On our workstations' keyboards, the keys marked <Ctrl> ("control") and <Alt> ("alt" or "meta") are somewhat like <Shift> keys, in the sense that they modify the effect of other keys that are pressed simultaneously.) The shell program interprets <Ctrl/d> as a signal that you have no more instructions for it and halts, and the terminal terminal emulator closes the window automatically once the shell stops running.

If you want to set the window aside for the moment, with the possibility of returning to it later, look closely at the upper right-hand corner of the window, where the frame contains a small bar or underscore character; if you move the pointer into that square and click on the left mouse button, you minimize the window, closing it up into a small rectangular icon along the bottom control panel on the screen. A minimized window can be restored by moving the pointer onto its icon and clicking the left mouse button twice in rapid succession.

Changing Your Password

You should change the password associated with your account shortly after you receive it and every few months thereafter. The password program lets you make this change.

  1. Choose a new password. Make it something that you can easily remember, but not an English word or a name, since it is easy for system crackers to break in by guessing your password if you choose it from one of those categories.

  2. Open a terminal window, move the pointer into it, and type the word password. The password program will prompt you once for your old password — the one you logged in with — and twice for your new password. If you give your old password correctly and the two copies of your new password match, the program will substitute the new password for the old one in the table that the login program consults. The old password will be discarded and will not be recognized in subsequent logins. (If the attempt to change the password fails for any reason, however, the old password will be retained.)

After running the password program, the shell takes over again and issues another prompt. You can invoke as many programs as you like from the shell, one after another, before pressing <Ctrl/d> to leave the shell.


Notes on the History of Scheme

Lisp was invented in the late 1950's and early 1960's at M.I.T. by John McCarthy. Lisp is based in part on the Lambda Calculus, a mathematical formalism developed by Alonzo Church (1903-1995).

Lisp is the second-oldest language still in widespread use (the oldest is FORTRAN). Two dialects of Lisp are widely used today: Scheme and Common Lisp. Scheme is a small, uniform dialect that is good for teaching because of its simplicity. Common Lisp is a large, "industrial-strength" dialect that is standardized and is available in several commercial versions. For most of this course, we will use an implementation of Scheme called DrScheme .

Most programming languages require learning the syntax of many different kinds of statements. In contrast, Scheme (and Lisp) syntax is simple and uniform. Much of the work in learning Scheme is learning the names and effects of the system functions that form the core of the language. This course presents the system functions and covers other functions that are present in Common Lisp.

Historically, Lisp has been used especially for work in artificial intelligence and scripting applications. For example, CS 261, Artificial Intelligence, uses programming in LISP in its study of expert systems. Today, Lisp is used in a wide range of applications, including the GNOME window system and the the emacs editor.

Running Scheme with Dr. Scheme

The Campus Linux Network supports several Scheme programming environments. For this course, we will use an integrated programming environment, called DrScheme. Many of the fundamental ideas of computer science are best learned by reading, writing, and executing small computer programs that illustrate them; and Dr. Scheme is particularly helpful in making this type of programming interaction easy.

To start DrScheme, move the pointer onto the red, white, and blue lambda-in-a circle icon on the front panel and click the left mouse button. It takes a few seconds for DrScheme to start up completely.

DrScheme language options

DrScheme can deal with computer programs written in any of four dialects of the Scheme programming language. In order to be consistent with our course materials, we're going to proceed directly to the "Graphical" option, which is quite close to the national standard. This version is consistent with our course materials.

Choosing the Scheme Dialect at First Use

When you start DrScheme for the first time, it may ask you which dialect you want to use. In this case, you should look for the little triangle next to "PLT". Click on this option, if needed, so that the triangle points down. Three options should appear below "PLT". Click on the second of these options, "Graphical (MrEd, includes MzScheme)". Move the mouse pointer onto the word OK and click the left mouse button. Now proceed with Dr. Scheme to get the regular interface.

Choosing the Scheme Dialect Anytime

If DrScheme does not ask you about the appropriate dialect, it may expect you to use Beginning Student Scheme, which is a kind of training-wheels dialect that enables DrScheme to catch and diagnose some common mistakes of novice programmers. As noted above, however, we're going to proceed directly to "Graphical," which is more nearly standard. To inform DrScheme of this decision, we'll need an operation accessed through the menu bar. Move the mouse pointer onto the word Language on the menu bar and click the left mouse button to bring up the Language menu. Move the mouse pointer onto the phrase Choose Language and click the left mouse button again to select that operation. Another window appears:

Click on the little triangle next to "PLT" so that it is now pointed down. Three options should appear below "PLT". Click on the second of these new options, "Graphical (MrEd, includes MzScheme)". Move the mouse pointer onto the word OK and click the left mouse button. The extra window disappears, leaving the DrScheme window. Next, move the mouse pointer onto the word Execute (next to a green arrow, just below the menu bar) and press the left mouse button. DrScheme now expects programs in the dialect it calls "Graphical (MrEd, includes MzScheme)." This simply means that it will accept all valid Scheme commands, whereas the other language choices are simply subsets of the full set of commands.

Three options should appear below "PLT". Click on the second of these options, "Graphical (MrEd, includes MzScheme)". Move the mouse pointer onto the word OK and click the left mouse button.

Click on the little triangle next to "PLT" so that it is now pointed down. Three options should appear below "PLT". Click on the second of these new options, "Graphical (MrEd, includes MzScheme)". Move the mouse pointer onto the word OK and click the left mouse button. The extra window disappears, leaving the DrScheme window. Next, move the mouse pointer onto the word Execute (next to a green arrow, just below the menu bar) and press the left mouse button. DrScheme now expects programs in the dialect it calls "Graphical (MrEd, includes MzScheme)." This simply means that it will accept all valid Scheme commands, whereas the other language choices are simply subsets of the full set of commands.

After the Scheme Dialect is Chosen

DrScheme retains the information that you prefer to use the full set of Scheme commands, so that when you log in again tomorrow and start DrScheme again, it will automatically expect programs in that dialect. You won't need to use the Choose Language operation again unless you decide that you'd like to experiment with Beginning Student Scheme or some other dialect.

Using DrScheme

When DrScheme comes up, you'll see a new window, with two white rectangular text areas against a dark gray background:

(screenshot)

Exiting from DrScheme

At the top of the window, just below the frame, is a menu bar, providing ways of activating various operations that DrScheme can perform. Move the pointer onto the word File at the left end of the menu bar and click the left mouse button to bring up a menu. Move the mouse pointer onto the word Quit at the bottom of this menu and click the left mouse button. DrScheme responds by popping up a confirmation box of its own, the purpose of which is to make sure that you don't shut down DrScheme by mistake:

(screenshot)

Move the mouse pointer onto the word Quit in the confirmation box and click the left mouse button. Both the confirmation box and the main DrScheme window disappear.


Working within Scheme

  1. We will begin our processing in Scheme by typing expressions directly into the bottom "Interactions" window within DrScheme. After each expression is entered, Scheme

    This read-eval-print cycle forms the basis for all processing within Scheme.

    For example, if we type (sqrt 1024) into Scheme, the environment identifies sqrt as an operation to be applied to the number 1024. The computer then evaluates this expression, and concludes by printing the number 32 at the end.

  2. Numbers are expressions, whose value or meaning is the number itself. Scheme recognizes several types of numbers, including the following:

  3. Numeric Procedures: As illustrated above, in Scheme we apply operations to data using a prefix notation with parentheses. For example, the function f(x) would be written (f x). Some common numeric operations follow.
        (+ 27 3.1415926535)
        (- 27 3)
        (/ 17 2)
        (/ 17 -2)
        (* 17 2.0)
        (sqrt 4)
        (sin 0.5)
        (sqrt -2)
        (+ (* 3 2) (/ 8 4))
    

  4. Symbols are Scheme's analog of words; symbols are sequences of characters, such as
        TwoBeOrNot2Be
        This-is-a-symbol.
    

    In Scheme, symbols may act as variable names, but they do not have a value until we give them one.

  5. Binding: We may give a symbol a value using a define operation. For example, we might give the symbol pi the value 3.141592 as follows:

         (define pi 3.141592)
    

    Similarly, we can give the symbol radical-2 the value of the square root of two as follows:

         (define radical-2 (sqrt 2))
    

    When using define, the symbol is given the current value of the expression that follows.


This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~walker/courses/153.sp09/readings/reading-getting-started.shtml

created 29 December 1996 by John David Stone
last revised 31 March 2008 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.