Studying SICP with emacs
Credits #
Thanks to this post by Konstantinos Chousos which already covered all of this information.
Introduction #
SICP, or the Structure and Interpretation of Compupter Programs, also known as the Wizard book, is a famous Computer Science book. It was used for the intro to CompSci course at MIT for many years, and I quite enjoyed it. Here’s a nice way to enjoy it on emacs.
Installation #
Racket VS MIT Scheme
#
Using your package manager of choice, install racket. It carries with it a bunch of schemes and LISPs. My first time through the book, I used MIT Scheme, but it’s not quite the same. This version is closer to the one they made for the book.
If you want to install racket without a package manager, you can also do that with their install script, easy to find on their website.
Getting to work with the correct scheme #
You can either follow the following instructions (found here):
Use DrRacket to install the sicp package like this:
1. Open the Package Manager: in DrRacket choose the menu "File" then choose "Package Manager...".
2. In the tab "Do What I Mean" find the text field and enter: sicp
3. Finally click the "Install" button.
4. Test it. Make sure DrRacket has "Determine language from source" in the bottom left corner. Write the following program and click run:
#lang sicp
(inc 42)
The expected output is 43.
Or alternatively use the following command line function: raco pkg install sicp.
Then you can just use #lang sicp at the top of all your scripts!
Setting up emacs #
There are two packages that can be useful. The first one is sicp and the second one is racket-mode:
(use-package sicp
:ensure t)
(use-package racket-mode
:ensure t)
The first package allows you to access sicp in texinfo format, so you can type C-h i and find SICP there to go through. The second is a bunch of utilities.
Then, make a .rkt file, start it with #lang sicp and run it with M-x racket-run. The magic happens now: once the REPL is running with M-x racket-run, you can run any expression into the REPL by using C-x C-e like you would any elisp!