Development Environment for SICP Journey
In order to be able to cast your spells, you need a good wand!
As you start with your journey to become a sorcerer, you will need a good set of tools for practicing to cast some spells.
In your journey to learn how to control your powers with the help of SICP, you may lost in the first place due to lack of knowledge of what tools to use.
Since the book is relatively old -but the information in it is rustproof- it can be a little hard to gather modern tooling. Fortunately, some sorcerers from far lands who are still practicing these teachings, are created a modern tooling for us to utilize. We will use the power of Racket to cast our spells!
In this article we will propose two different setups which will accompany you along with this journey, you are free to choose which suits best for you.
First Option: DrRacket
DrRacket is a graphical environment for developing programs using the Racket programming languages. We will install a special package specifically created for practicing SICP.
Firstly, you need to install DrRacket by choosing proper platform for you.
After you completed the setup;
- Go to File > Package Manager from top menu
- Write ‘sicp’ to Package Source input field then click install.
- Make sure The Racket Language is selected from Language > Choose Language… from the top menu, by this way we will be able to specify which language we want to use for our programs.
Lest test it out! Copy following program and run it on DrRacket.
#lang sicp(define A (inc 5))A
You should see the output 6
at the bottom panel.
As you may have noticed, we are starting to write our program with #lang sicp
statement to inform Racket to run it properly.
Second Option: VSCode
If you are already using a modern editor, DrRacket can feel little bit odd. So other option is installing the Racket and SICP language package separately from DrRacket and write the code from VSCode with the help of several extensions.
Installing Racket
First of all Racket installation differs with respect to your platform. We are listing the commands for several platforms below. If your platform missing, you can find installation instructions by a quick Google search.
Note: If you are using Windows, it may be quicker to install Linux on your machine and then Racket in it.
Ubuntu
sudo apt-get update -y
apt-get install -y racket
Arch Linux
sudo pacman -S racket
MacOS
brew tap caskroom/cask
brew install racket
Installing SICP Language Package
After installing Racket, you need to install sicp
package using raco
which is the package manager or Racket.
raco pkg install sicp
We are done with the Racket setup!
Installing VSCode and Extensions
Install VSCode from here.
Following extensions can ease your development process in VSCode:
- vscode-scheme
- Bracket Pair Colorizer
- Bracket Select
Development in VSCode
As a sorcerer’s apprentice, it is beneficial for you to keep your work tidy. So, we recommend you to create a folder for your experiments and organize your work in it. You can create your folder and files from your file browser, still we are providing necessary commands to do it from command line.
- Create a folder for your source code files i.e.
my_sicp_exercises
- Navigate in that folder and create a scheme source file i.e.
first.scm
- Open your folder from VSCode
Command line way:
cd ~/
mkdir my_sicp_exercises
cd my_sicp_exercises
touch first.scm
code .
Paste following code inside first.scm
and save it.
#lang sicp(define A (inc 5))A
Running the program
You need to go to your source code directory from command line. If you followed the command line way above, running following lines should run the program. If you created your files from file browser, navigating to your folder from command line left as an exercise for you.
cd ~/my_sicp_exercises
racket first.scm
You should see the output 6
in your terminal.
It seems you are ready to embark on your adventure. Don’t settle with this and always seek for new tooling which can ease your work. Will see you soon!