Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been meaning to read the SICP book for a while, and am finally about to get around to it (now that I can read it on Kindle :) I'd like to learn a functional language, and I use C# at work so thought it might be a good idea to go through the book with F# in my mind rather than Scheme. (That is, do the exercises in F#.)

I wonder though, will there be much mental disjoint between Scheme and F#? Maybe it's better to go through with Scheme on the first pass?

share|improve this question

closed as not a real question by gnat, Glenn Nelson, Kilian Foth, GlenH7, MichaelT Feb 6 '13 at 14:33

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

You are probably best off just using Scheme. It is an easy language to learn, really. You might want to try to do some things in F# as well, but start with scheme.

share|improve this answer
Do you have experience on Scheme and F#? Are there fundamental differences between the languages that make F# unsuitable for SICP? – simoraman Apr 11 '11 at 6:31
Scheme yes, F# no. The reason I said to use scheme is that SICP has all its examples in Scheme, and was written assuming that the reader would be using scheme. Some of the later chapters may actually use macros (I forget) which are a lisp only thing. – Zachary K Apr 11 '11 at 6:33
+1 on this, not from personal experience, but from reading about those trying to do SICP with Clojure. Some of them struggle a good deal and Clojure is much closer to Scheme than F# is. – Brian Knoblauch Feb 27 '12 at 20:46
"Are there fundamental differences between the languages that make F# unsuitable for SICP?" Yes. F# has a strong emphasis on typeful programming. SICP uses Scheme which is incapable of typeful programming because it is dynamically typed. The solutions presented in SICP are all typeless. A faithful translation would be extremely hard even for the most seasoned expert. You can solve the same problems in F# but idiomatic solutions would often bear little resemblance to those given in SICP. – Jon Harrop Apr 30 '12 at 13:53
@BrianKnoblauch, do you mind elaborating why people who try to do SICP exercises in Clojure struggle with it? – Nameless Feb 15 at 11:26

There are two Lisps that can deploy to .NET. Clojure is one and IronScheme is the other. I'd recommend doing the exercises in one of those two or just taking the Scheme level course and adapting the knowledge gained to one of those two later. ML family languages tend to be radically different from Lisps. It's still a doable thing, it will just be more of a leap.

share|improve this answer

Doing the exercises in F# is doable, but will get progressively more difficult as you proceed through the book.

Starting with Chapter 4, the book focuses on implementing Scheme: starting with a interpreter and progressing to a compiler for a simulated register machine. Early iterations of the interpreter delegate much of the evaluation work to the Scheme runtime. All of them rely on Scheme's built-in S-expression reader.

If you plan to do the exercises for the later chapters in F# you can expect to spend a fair amount of effort re-implementing parts of the Scheme runtime in F#.

share|improve this answer

You might be interested in looking at a semi-long term project of mine - working through SICP in Haskell.

There are some complications - for example, the entire section on mutability is tricky in Haskell since if you want mutability you have to work in a monad that allows it! But overall it's been a fun challenge, and I've learned a lot.

share|improve this answer

I wonder though, will there be much mental disjoint between Scheme and F#? Maybe it's better to go through with Scheme on the first pass?

If your objective is to learn the lessons that SICP was written to teach then you should definitely use Scheme to go through SICP for the first time. However, you must remember that SICP is 28 years out of date now (!). In particular, it fails to leverage typeful programming at all (Scheme is dynamically typed and, consequently, cannot even represent such things). If you don't already understand this then I would advise against trying to go through SICP using F#.

share|improve this answer
I would not say it is 28 years out of date, I personally think it is very much a current work, as the goal of SICP is to teach you how to reason about computation. Being able to reason about what your code is doing is as important now as it was when SICP was first published back in the '80s. It should also be noted that SICP was created to be the first block in a CS Program, not all of it. If perfection is left when there is nothing left to take away Scheme really ranks rather well in that spectrum – Zachary K Feb 27 '12 at 10:44
@ZacharyK "Being able to reason about what your code is doing is as important now as it was when SICP was first published back in the '80s". Absolutely but the way we reason about code has changed enormously over the past 28 years. – Jon Harrop Feb 27 '12 at 20:26
in some ways yes and in some ways no, I still think it is a wonderful book – Zachary K Feb 28 '12 at 6:41
First, a second edition was published in '96, so it was updated as of 16 years ago. Second, asserting that the book is "out of date" because different tools are in vogue now is like calling Hamlet out of date because we don't speak in iambic pentameter. I don't think most of the industry worked in the style of SICP in '84 or '96 any more than people in the 16th century spoke in meter, but that doesn't mean that the lessons aren't now or weren't then valuable. – Caleb Apr 19 '12 at 14:12
@Caleb Strawman argument. My reasoning was about typeful programming and had nothing to do with "vogue". My argument was not that the lessons are not valuable, it was that the lessons would be lost in translation, i.e. incomprehensible. – Jon Harrop Apr 30 '12 at 13:57

I've been in the same case as you, trying to learn functional programming coming from a C# background. I bought the book and though I'm only about 1/3 through it currently (it involves quite a lot of math which bugged me a little), I can already say I wouldn't recommend doing the exercises with a non-lisp language. The F# syntax is quite different from that of Lisp dialects so it would cost you quite a lot of effort in translating the exercises and I think it's better to concentrate on learning one thing at a time.

As a side note, I'd really recommend you watch at least the few first SICP lectures videos from the 80's in parallel to reading the book for a deeper understanding of the subject. While they can look like funny vintage objects from a distance, they're really targeted at beginners and still contain many nuggets of truth about software development that are surprisingly valid today.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.