74

I have been using PLT Scheme, but it has some issues. Does anyone know of a better implementation for working through SICP?

Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
Joel McCracken
  • 2,275
  • 3
  • 17
  • 11

8 Answers8

95

Use Racket (formerly PLT Scheme).

The DrRacket IDE is an excellent starting point for all things Scheme including SICP.

To look up keywords in the documentation, place the cursor on the keyword and press F1. In DrRacket you can now see the images directly in the REPL (the read-eval-print-loop).

SICP Support for DrRacket, by Neil van Dyke.

Update (2016): The new SICP package is at http://pkgs.racket-lang.org/#[sicp] Download it with the Package Manager (in DrRacket) or use raco. Manual

Update2 (2016): Also if you want to try a new implementation of the SICP picture language, then download sicp-pict2.rkt.


Update3 (2020): The sicp-lang package includes an implementation of the sicp language and the sicp picture language.

Documentation: SICP Support for DrRacket
Source Code: sicp-lang on GitHub
Racket Package: sicp-lang package info

Note: The picture language has more features (such as colors and larger sizes) than the picture language described in the book. The source contains examples: https://github.com/sicp-lang/sicp/blob/master/sicp-pict/main.rkt

Will Ness
  • 70,110
  • 9
  • 98
  • 181
soegaard
  • 30,661
  • 4
  • 57
  • 106
  • 7
    Note: Neil van Dyke has written a very nice SICP package for Racket. Use this instead of my old one. – soegaard Mar 07 '12 at 21:05
  • hmm OP asked about PLT Scheme which became DrScheme and then DrRacket and finally Rocket lang now. – FUD May 29 '13 at 17:42
  • Warning: it's impossible to securely install the SICP support package. When you run that code (`#lang planet neil/sicp`), it tries to download stuff via plain http, so MitM attacks are possible. And when downloading code which will be executed on your machine, _this is a big deal._ The page isn't available through https, that's also means you can get anything at all instead of the content. I hope the author will fix it at some time. – Display Name Jul 09 '16 at 11:40
  • Don't worry. The SICP package has moved from PLaneT to pkgs.racket-lang.org. – soegaard Jul 09 '16 at 14:09
  • Note: The picture language has more features (such as colors and larger sizes) than the picture language described in the book. The source contains examples: https://github.com/sicp-lang/sicp/blob/master/sicp-pict/main.rkt – soegaard Feb 12 '20 at 16:27
  • Downvote, because DrRacket does not work at all. If you write `#lang sicp` as stated in the sicp plugin documentation, all you get is `read-syntax: `#lang` not enabled`. – Philipp Ludwig Dec 10 '21 at 12:50
  • @PhilippLudwig you need to install the sicp package first. Choose the package manager in … one of the first menus of DrRacket. – soegaard Dec 10 '21 at 12:53
  • @soegaard Of course I installed it according to the documentation; it still does not work. – Philipp Ludwig Dec 10 '21 at 12:57
  • @PhilippLudwig which version of racket an is do you have? It’s supposed to work. – soegaard Dec 10 '21 at 13:01
  • @soegaard Version 8.2. – Philipp Ludwig Dec 10 '21 at 13:20
  • @PhilippLudwig I just tested on version 8.3.0.2 on macOS and that worked. StackOverflow is not the best medium for trouble shooting. Can I get you to submit an issue here instead? https://github.com/sicp-lang/sicp/issues – soegaard Dec 10 '21 at 13:26
  • @PhilippLudwig Ah! I figured out what's wrong. In the lower left corner of DrRacket, you will need to change the languge to "Determine language from source". – soegaard Dec 10 '21 at 13:27
  • @soegaard I did that, it still does not work. I will just leave it at that, but thanks for your support. – Philipp Ludwig Dec 10 '21 at 13:33
  • @PhilippLudwig Which error do you see? On Github you can send a screen shot. – soegaard Dec 10 '21 at 13:34
  • 1
    @soegaard Okay, I figured it out. You have to type `#lang sicp` in the upper window, not at the prompt in the lower Window. I was not aware of that. – Philipp Ludwig Dec 10 '21 at 13:37
  • installation commands: `raco pkg install sicp`, use in REPL: `(require sicp)`, then enter `(inc 1)` to test. – SodaCris May 15 '22 at 10:43
68

Use MIT Scheme.

It's recommended by the authors of SICP, and is used at MIT for the 6.001: Structure and Interpretation of Computer Programs course.

keparo
  • 33,450
  • 13
  • 60
  • 66
  • 18
    The thing I didn't like about MIT Scheme was that I couldn't figure out how to simply execute a scheme script from the command-line and have its output displayed in my console - the same way I'd expect to run a Python or Ruby script. Was I being extremely dense? How is this achieved, without launching the big interactive Emacs-based environment and then having to quit it again every time? – Jonathan Hartley Apr 10 '11 at 20:24
  • there is a pre built 64 bit version of mit-scheme here - [http://www-users.cselabs.umn.edu/classes/Fall-2010/csci1901/mit-scheme-x64_9.0.1-1_amd64.deb] – tutysara May 26 '12 at 03:16
  • Just successfully compiled it on Ubuntu X64 using the source provided on GNU site. – Bernard Notarianni Dec 27 '12 at 13:41
  • @f4hy I suspect that a 32-bit version would work fine on x86_64 – offby1 Oct 14 '14 at 18:05
  • 3
    To exec from command line: http://stackoverflow.com/questions/24720112/mit-scheme-run-a-script-and-exit – Gringo Suave Feb 11 '17 at 07:58
  • 3
    @JonathanHartley [How do I execute a .scm script (outside of the REPL) with MIT-Scheme?](https://stackoverflow.com/q/903968/5916915) – Flux Jul 08 '19 at 06:07
13

This was suprisingly annoying to get done on macOS. Here's how it works as of today, assuming you have Homebrew. (Might want to run brew update once in a while).

brew cask install racket
raco setup  # might be optional
raco pkg install sicp

Now you can (require sicp) or simply run

racket -l sicp --repl

Which you might want to abbreviate to scheme. In bash that'd be

alias scheme='racket -l sicp --repl'

which you can add to your ~/.bashrc

Frederick Squid
  • 591
  • 4
  • 16
12

MIT/GNU Scheme, just make sure you load the SICP compatibility package (yes, they provide specific libraries to enhance guarantee the SICP exercises work).

Louis Gerbarg
  • 43,356
  • 8
  • 80
  • 90
6

I've just started do SICP this week.

Currently, MIT Scheme is broken in in Ubuntu Linux (9.04 "jaunty"). It might be working in the future.

DrScheme is working, and is working well. You can use soegard's package listed above or Neil Van Dyke's package, which is based on soegard's package and is available from http://www.neilvandyke.org/sicp-plt/. The nice thing about this package is that when installed, you can use Language|Choose Language.... menu item to select SICP.

gdimike
  • 61
  • 1
  • 2
2

CHICKEN Scheme has an sicp library that provides support for SICP. You can install it by running chicken-install sicp and writing this at the beginning of your source code: (use sicp).

htanata
  • 36,666
  • 8
  • 50
  • 57
  • 2
    With CHICKEN Scheme 5.2.0, we use two SRFIs : 203 and 216. `chicken-install srfi-203` and `chicken-install srfi-216`. – Ludovic Kuty Aug 15 '21 at 14:36
1

PLT Scheme works pretty well, or MIT Scheme as Keparo suggested. What issues are you having with it?

Matt Curtis
  • 23,168
  • 8
  • 60
  • 63
0

I'm now working through SICP using Chez Scheme. It's a pretty old dialect of Scheme, so presumably it isn't too far from what SICP was written around.

Note that the Chez Scheme project page links a Windows binary and source that can be built on Unix-like platforms. But if you're on a Mac, you'll probably want to do

brew chezscheme
man chez

Assuming you have homebrew, which you really should.

Why not MIT Scheme? Because the interactive front end is Edwin, an editor that uses EMACS conventions. (Currently, it's an actual EMACS mode, tho it used to be implemented in Scheme.) I used to know basic EMACS, but my skills atrophied from disuse, which tells me that relearning this editor is just not worth the trouble.

Why not DrRacket? If I had seen @frederick-squid 's brew instructions, I might have given it a try. Instead I tried to follow the official instructions for scheme and sicp, which are seriously out of date. Then I tried to make the IDE go into scheme mode, which seems to be intuitive but isn't.

Just too much trouble. And I'm not sure I want to get into a fancy language design IDE, especially one whose poor support of Scheme sparked the original question.

  • You do not have to use Edwin to run MIT-Scheme. Edwin is just specified as an option on the command line script, which you can change. I run MIT-Scheme under Emacs(24), set up as the default scheme implementation, so that M-x 'run-scheme' instantly fires up the MIT environment that I want (mechanics/scmutils). It is surprisingly easy if you just think about it a bit. The Dr Racket interface with the '#lang sicp' option is very good too, we've come a long way from the bad old days... (All this on Ubuntu, 16.04 LTS) – Alex Gian Sep 04 '18 at 09:13
  • Did you notice that I said that I don't want to re-learn EMACS? If you could point me at command line docs that I could use to integrate MIT Scheme with my favorite editor, that would be useful information. – Isaac Rabinovitch Sep 04 '18 at 17:07
  • Sorry, I have no docs to hand, but MIT-Scheme is not tied to any editor. If you cd to your mit-scheme installation directory (the one that has just a bin and a lib directory in it), the the following command should get you going: >> `bin/mit-scheme --library ./lib --heap 120000` << . After that it's up to you to configure it with your "favourite editor". Or just use the command line as a repl and load whatever file you want from your ed. – Alex Gian Sep 04 '18 at 22:29
  • 1
    So, instead of "You have to use edwin" I should have said "You have to use edwin unless you're willing to use a complicated, undocumented hack." Thanks for the correction. – Isaac Rabinovitch Sep 05 '18 at 02:56