SICP Explorations Part 1 - Starting the journey

15 Mar 2019

🔖 computer-science functional-programming

I have started reading the below book called ‘Structure and Interpretations of Computer Programs’ also known as the SICP or the ‘wizard book’.

sicp cover image

It is a computer science textbook which was written by Harold Abelson and Gerald Sussman during the 1980’s for the 6.001 course at Massachusetts Institute Of Technology, which was MIT’s introductory course in electrical engineering and computer science. Though the 6.001 course is no longer taught at MIT, the concepts taught in the book are timeless. Also, see the reviews of the book by Peter Norvig and Paul Graham here and here.

The book teaches how large and complex systems can be designed by abstraction and i think is a must read for anyone aspiring to be a better software engineer. It uses Scheme, which is a dialect of Lisp, as the programming language for implementation of the concepts discussed.However, no prior Lisp experience is necessary as the authors teach everything required to know from the ground up.

To quote Peter Norvig ‘If SICP were about automobiles, it would be for the person who wants to know how cars work, how they are built, and how one might design fuel-efficient, safe, reliable vehicles for the 21st century. The people who hate SICP are the ones who just want to know how to drive their car on the highway, just like everyone else’. So the focus of the book is not on using a programming language to write computer programs but rather on understanding the fundamental process of computation itself and how programming languages work under the hood.

This is definitely a challenging book, not for the faint hearted and i have had to read a lot of sections more than once to finally grok what the authors are trying to convey. I want to read it slowly and i hope i am finally able to read and understand the whole book 🙂.

One of the challenges for someone like me reading this book with no prior Lisp experience is getting used to the parenthesis style of writing code. Therefore it is very important to have a good development setup for working on the examples and exercises given in the book. On my macOS machine, i have installed MIT Scheme and Emacs 26 using Homebrew and i run Emacs in my iTerm2 terminal. SICP and Emacs for the Vim User is a great article that helped me set everything up.

There are other ways of running Scheme programs for the SICP book like the beginner friendly DrRacket IDE with the SICP Collections package or using Vim with Racket for example. For the curious, Scheme is a programming language that has many implementations, MIT Scheme and Racket being two of them.

Emacs with MIT Scheme has been working great for me so far. The ability to do inline evaluation of symbolic expressions using the REPL running in a split window is just awesome !. There is also a way to use Vim keybindings, if you so prefer, using Evil Mode in Emacs!. This is good for someone who is new to Emacs but has experience with Vim, so they can continue to use the key-bindings they already know instead of spending time to learn new ones. However, as i have some prior experience with Emacs i choose to use it without Evil mode.

One gotcha was that to get the META key of Emacs to work in iTerm2 i had to map the Left Option and Right Option Key to Esc+ for the Keys settings for my iTerm2 profile as shown below.

iterm2 settings

Also, i added (show-paren-mode 1) to my .emacs to highlight matching parenthesis which is super handy. Im using the Zenburn theme for Emacs which i installed using MELPA, the package archive for emacs. Also, enabled line numbers in my emacs config. My emacs config is located at GitHub. Thats it for this post and i will post more stuff as i continue to progress through my SICP journey. Wish me luck ! 🙂 .