Top
Best
New

Posted by gjvc 18 hours ago

Structure and Interpretation of Computer Programs Video Lectures (1986)(ocw.mit.edu)
292 points | 41 commentspage 2
songbird23 13 hours ago|
Should I do the JS or Scheme SICP
ughitsaaron 3 hours ago||
Part of the point of SICP is to be generic about its programming principles. The core principles and concepts are independent of any particular programming language (so long as it has first class functions, and probably a few other common features). Since Scheme has virtually no syntax it was an ideal language for Ableson & Sussman’s course. It’s notable that SICP spends hardly any time teaching the language.

I’ve never understood, therefore, the motivation behind trying to “translate” SICP into a language like JS (or Python, etc.) It over emphasizes the importance of the preferred language in a way that very obviously undermines the book.

The point being: if you’re gonna do SICP do it in Scheme. You’ll get more out of it.

nobleach 6 hours ago|||
The JS version of the book (I still bought it when it came out) is just weird. It has you writing JS in a non-idiomatic way that you'd never see (nor should you be the person introducing) in the industry. SICP teaches a very LISP-y way of thinking through problems. It's not that you CAN'T apply these tactics in other languages... they're just far more "at home" in Scheme/DrRacket/heck... even Clojure.
Nekorosu 10 hours ago|||
I have both books. Scheme for sure! Env setup can be a bit of an issue but it is doable. Regarding it, I remember having some weird issues with MIT Scheme on a modern computer, but Racket/DrRacket works well.
brudgers 11 hours ago|||
Scheme. Javascript is a fine language, but it is not the right tool for this job.
spauldo 7 hours ago|||
I'll add another recommendation for Scheme. The concepts in SICP map very well into Scheme, whereas I can only imagine them being awkward and non-idiomatic in JS. There's lots of passing around first class functions and use of recursion.

One of the two professors (Dr. Sussman) that give the lectures in this series is a co-creator of Scheme.

Jtsummers 56 minutes ago||
> I can only imagine them being awkward and non-idiomatic in JS

You don't have to imagine, you can look at the code used in the JS version and it goes through some fun contortions to get around the fact that JS is not expression oriented (like Scheme). This is from page 35 (PDF: https://sicp.sourceacademy.org/sicpjs.pdf):

  function count_change(amount) {
    return cc(amount, 5);
  }
  function cc(amount, kinds_of_coins) {
    return amount === 0
           ? 1
           : amount < 0 || kinds_of_coins === 0
           ? 0
           : cc(amount, kinds_of_coins - 1)
             +
             cc(amount - first_denomination(kinds_of_coins),
                kinds_of_coins);
  }
  function first_denomination(kinds_of_coins) {
    return kinds_of_coins === 1 ? 1
           : kinds_of_coins === 2 ? 5
           : kinds_of_coins === 3 ? 10
           : kinds_of_coins === 4 ? 25
           : kinds_of_coins === 5 ? 50
           : 0;
}

That certainly works, but it's awkward. Here's the Scheme code from the 2nd edition of SICP:

  (define (count-change amount) (cc amount 5))
  (define (cc amount kinds-of-coins)
    (cond ((= amount 0) 1)
          ((or (< amount 0) (= kinds-of-coins 0)) 0)
          (else (+ (cc amount
                       (- kinds-of-coins 1))
                   (cc (- amount
                          (first-denomination
                           kinds-of-coins))
                       kinds-of-coins)))))
  (define (first-denomination kinds-of-coins)
    (cond ((= kinds-of-coins 1) 1)
          ((= kinds-of-coins 2) 5)
          ((= kinds-of-coins 3) 10)
          ((= kinds-of-coins 4) 25)
          ((= kinds-of-coins 5) 50)))
The JS code has to use the ternary ?: to get around the fact that it does not have a good equivalent to `cond`. You can see that they've gone through a literal translation of Scheme to JS that results in very unidiomatic JS code.
submeta 12 hours ago||
I‘d go with Scheme. You‘ll learn the basics in a day. The language spec is only a few pages. And Scheme reads like pseudo-code with parentheses.
aligutierrez 13 hours ago||
interesting approach to SICP.
aag 7 hours ago|
I don't understand this comment. They wrote SICP.
tangsoupgallery 16 hours ago||
These 1986 lectures are the definitive SICP experience — the Hal and Gerry show at its peak. The presentation quality holds up remarkably well, and seeing the metacircular evaluator built live is something no textbook can fully capture. For those who find the book dense, these lectures provide the pacing and intuition that make the abstractions click.
ramchip 8 hours ago|
LLM bot account