Using Racket for SICP

Tags: racket, SICP, lisp, scheme

Racket is a general-purpose programming language based on the Scheme dialect of Lisp1. In fact Racket is a family of programming languages well suited to language development. On OpenBSD the relevant package to install is minimal-racket which provides the racket interpreter but not the DrRacket IDE by default. However, there is a sicp package for Racket which can be installed using the Racket raco packge manager by typing into a terminal raco pkg install sicp which pulls in a whole bunch of dependencies including drracket.

When compiled DrRacket can be launched from the terminal with the drracket command. However, this presupposes that the installation location of DrRackt is in your PATH variable in your environment. On OpenBSD DrRacket was installed to /home/chris/.racket/7.8/bin/ hence it was necessary to added this directory to the PATH variable specified in .profile.

The version of the Scheme programming language used in the SICP book is a subset of the Scheme programming language which has itself evolved since the book was written2. The sicp Racket package makes this subset of Scheme available for those studying SICP. It can be enabled by adding #lang sicp to Racket source (.rkt) files. The racket interpreter can be invoked in a terminal by typing racket. Append the name of a specific .rkt file to run it from the command line e.g. racket hello.rkt3. The DrRacket IDE provides a nice environment for working with code. This may be available in your desktop environment after installation or failing that can run from a terminal by typing drracket.