“Computer Science is a terrible name for this business. First of all, it’s not a science. It might be engineering, or it might be art… it’s also not really very much about computers.

It’s not about computers in the same sense that physics is not really about particle accelerators, and biology is not really about microscopes and petri dishes.

It’s very easy to confuse the essence of what you’re doing with the tools that you use, and indeed on some absolute scale of things we probably know less about the essence of Computer Science than the ancient egyptians really knew about geometry.

I think in the future, people will look back and say yes those primitives in the 20th century were fiddling around with these gadgets called computers, but really what they were really doing was starting to learn how to formalise intuitions about process.”

Harold Abelson Assoc. Prof EE & CS, MIT
Delving into Computer Science with SICP

The Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman is often cited by experienced developers as one of the books that fundamentally changed the way they think about computer science and software development.

SICP is also a somewhat intimidating tome that demands a fair bit of perseverance and dedication from its reader. Like most things in life of course, things worth doing typically take time and effort!


Why study sicp?

I suspect many developers today would see learning a language like Scheme as anachronistic, and potentially less than practical. Interestingly, there seems to have been a recent resurgence of interest in functional programming.

Javascript, which in the past has been a somewhat misunderstood language, is beginning to be recognised as capable of some fairly sophisticated constructs and a lot more than just behavioural glue for the DOM. Languages such as F# and Haskell are slowly beginning to work their way into the mainstream software development world. The latest version of Microsoft’s IDE, Visual Studio, is shipping with F# as a first class citizen, supporting .Net F# projects out of the box.

Chris Hanson posted the following on StackOverflow in response to a user enquiring about the value of working through SICP:

Even if you don’t do the exercises, it’s worth reading through Structure and Interpretation of Computer Programs at least once. Unlike The Art of Computer Programming it’s written not to appease some bizarre notion of machine architecture but to demonstrate the fundamentals of computational processes, and it excels at that.

Some of what you’ll learn simply by reading through SICP:

  • Functional decomposition and modeling problems
  • Recursion, its uses, pros and cons
  • Imperative and functional programming
  • Control structures, and why they have the behavior they do
  • Language design
  • Computer architecture
  • Compiler implementation.

The compiler implementation bits later on in the book will be especially enlightening to many working software developers, who if they haven’t had a class on the topic often think compilers are strange and mysterious beasts and that creating languages is “hard.”

My feeling is that a lot of people suggest reading The Art of Computer Programming because having waded through it makes you feel smart, but that people suggest reading Structure and Interpretation of Computer Programming because it clearly presents knowledge every software developer needs a thorough command of.

Expectations

I’m hoping to document my experience here on my blog to see if understanding the concepts in SICP will have any appreciable effect on the way I approach web development. Given that javascript is essentially a functional language, I suspect a lot of the concepts will be relevant. At the very least I hope to have a better understanding of computer science in general.

I won’t be alone in my journey - a number of others have blogged about their experience as they’ve worked through the book and the course material. Both Bill the Lizard and Eli Bendersky have some excellent posts both on the content of the lectures and working through the exercises.

Course resources

Complete SICP book html pdf

Lecture notes, Exams, Projects

Lecture Videos Also provided from the OCW site, but this page provides links to torrents.

SICP Tutor

Selecting a Scheme interpreter

There are an astounding number of Scheme implementations available today, and to the beginner this can be somewhat overwhelming. The Community Scheme Wiki has the following advice regarding choosing an implementation for learning Scheme:

Beginners should select an implementation that is well-documented, adheres closely to the standard, has good error handling and debugging capabilities, is easy to install, is mature, stable and under active development. Chez Scheme, Gambit, MIT Scheme and PLT Scheme are all used extensively in teaching Computer Science courses and hence meet all the aforementioned requirements. Chicken, Bigloo, EdScheme, OpenScheme, Scheme48, and SCM are quite beginner-friendly too.

I’ve decided to give Chicken a go, primarily because I find the name amusing, but also as it has POSIX support and provides both an interpreter and compiler. A fair bit of real world development appears to be done with Chicken, so there would be no need to switch implementations if I decided to start building apps in Scheme one day.

Setting up a Scheme environment in Mac OS X

Installing Chicken is a snap if you have Mac Ports installed - simply run:

sudo port install chicken

If you don’t have Mac Ports installed, the latest release is available from the Chicken website. You’ll need to have installed XCode to build Chicken from source.

Choosing a text editor

If you use TextMate, you’ll find the Scheme bundle helpful as it provides syntax hi-lighting and bindings for your Scheme interpreter such as ⌘R for Run Script. To install the bundle, run the following commands in Terminal:

mkdir /Library/Application\ Support/TextMate/Bundles/
svn co http://svn.textmate.org/trunk/Bundles/Scheme.tmbundle/
osascript -e 'tell app "TextMate" to reload bundles'

Any text editor that you’re comfortable with will be fine, but you’ll probably find life easier if you select one with some form of syntax hi-lighting and parenthesis matching for LISP/Scheme.

PLT Scheme provides a Scheme IDE called DrScheme, which runs on Windows, Linux and OS X.

Emacs is another popular option in the LISP/Scheme community, and available in many guises. Aquamacs is a good aqua interpretation for Mac OS X.

Managing multiple distinct logins in JMeter

I’ve recently been building a load model of the site I’m currently working on in JMeter, and struggled a bit to find a way to manage distinct user sessions in a thread group.

After some mild expletives, and a bit of digging around in the documentation I found the answer which I’ll clarify here as it’s not entirely obvious.

The best approach appears to be reading username and password pairs from a CSV.

First you will need to create a new csv with username and password pairs delimited by commas.

In Jmeter, add a CSV Data Set Config Element to your thread group, and specify the path to the CSV you just created, as well as setting “USERNAME, PASSWORD” in the Variable Names field.

In your Thread Group configuration, set the number of threads to the number of users you’ve specified in your CSV.

Next you’ll want to create a Once Only Controller, and set your HTTP Request sampler for your login process as a child. The Once Only logic controller will run only once per thread, so based on the configuration above, the HTTP POST to the sign in page will occur 10 times, whereas the HTTP Request sampler below will hit the app 500 times.

Finally, in your Sign In HTTP sampler, find the section labeled Send Parameters With the Request. Find the Name/Value pairs for your username, and password text boxes and set the respective values to ${USERNAME} and ${PASSWORD}.

An even simpler solution

Provided you have a group of test users with the same prefix and an appended incrementing int (testuser1, testuser2 etc.), an even simpler approach is to forgo the CSV node entirely and simply pass something like this to the HTTP sampler:

${username-prefix}$(__threadNum}

Simply define ${username-prefix} in your test plan’s user defined variables, and the $(__threadNum} function’s return value will increment once for every new thread.

Handy!