top | item 22994976

SICP in Python

253 points| crammyRL | 5 years ago |wizardforcel.gitbooks.io

125 comments

order
[+] jedberg|5 years ago|reply
It made me so sad when I found out CS61A was being taught in Python. I love Python, but I also know that I would have missed out on so much wonderful information if I hadn't learned Scheme.

It was truly mind blowing when they had us implement a Scheme interpreter in Scheme, and then add infix operators.

I think the original SICP was perfect for an intro course.

It was also the great leveler, because even if you entered college with programming experience, almost no one knew Scheme. So you were all on equal footing when it came to the language.

[+] trizzle21|5 years ago|reply
I believe the "self-paced" version is still in Scheme. I did it a couple years ago and it was awesome.

The final project was changed to a python interpreter in Scheme which I thought was fantastic.

[+] _revy|5 years ago|reply
Unlike most programming books the environment and code samples never go out of date either. It's entirely self contained including assembly language.
[+] lavp|5 years ago|reply
It just isn’t the same, Scheme was such a wonderful educational language.
[+] noah_buddy|5 years ago|reply
When did you attend? I heard from a mentor who'd gone way before me that it used to be taught in Lisp but I wonder if they actually meant Scheme.
[+] montebicyclelo|5 years ago|reply
Thank you for explaining why you think Scheme is a better langauge for SICP than Python.

As a fan of Python, my reaction to seeing this course was: "oh cool, a course on interesting things in a language I'm comfortable with".

I was then somewhat discombobulated to see the Python bashing in the comments.

[+] hf|5 years ago|reply
If you wanted to delve into the original 1984 LISP/Scheme version by Abelson and Sussman, I recommend you take a look at

https://opendocs.github.io/sicp/sicp.pdf

which is based on the MITPress HTML version, released under a permissive CC-by-SA license.

https://mitpress.mit.edu/sites/default/files/sicp/index.html

(nb. The pdf starts out with a curious little 'texinfo foreword'. Being able to type `info sicp` in one's shell? I wonder ...)

[+] neilv|5 years ago|reply
> The pdf starts out with a curious little 'texinfo foreword'. Being able to type `info sicp` in one's shell?

Yes, mostly in Emacs, but you could also do it in your shell. :) https://www.neilvandyke.org/sicp-texi/

The Texinfo format happened a couple years ago, in the early days of the Web, and let people on modest computers who couldn't run a Web browser work through SICP on their screens (no need for expense of printing to paper) while they also ran a Scheme interpreter on the same modest computer. The work was done by Lytha Ayth from the original freely-available HTML version of the book.

Later on, and now that everyone has more powerful computers, I've heard someone took the Texinfo source code, and replaced the ASCII-art illustrations with real ones, and ran it through TeX, such as for printing or PDF of "camera ready" format that looked similar to the original print book from MIT Press.

I wasn't involved in that much more recent TeX work, and though it was kind of them to preserve the version number with my name in it, I'll ask them to please remove it. (The name was part of some kind of distributed version-tracking scheme that Lytha Ayth proposed, when this seemed to be in the spirit of the original HTML release of the book. I tried to follow versioning instructions when I made changes to the Texinfo source, not knowing my name would show up 20 years later in a very different thing. :)

[+] cpach|5 years ago|reply
NB: That is actually the second edition from 1996.
[+] neilv|5 years ago|reply
Neat. The more, the merrier.

If anyone wants to work through SICP in the original way, you can get MIT Scheme, and run it on some computers.

sudo apt install mit-scheme

Some of us added support to DrRacket, for working through SICP that way (though if you already know how to use an editor, etc., you might prefer to just run MIT Scheme): https://docs.racket-lang.org/sicp-manual/

[+] Err_Eek|5 years ago|reply
I have been using #lang sicp in Racket to go through (most of) SICP -- and it's been mostly a smooth ride. DrRacket can get very slow on Linux, so eventually I switched back to vim+terminal once exercises started to require larger amounts of code.
[+] qpax|5 years ago|reply
"Processing Recursive Lists" is a good example of how Python is abused for all sorts of things.

If this is actually taught, I'm no longer surprised by the code that I encounter in the wild.

[+] nikofeyn|5 years ago|reply
i think this is rather dishonest to call this "SICP in Python" and the same goes for the title of this post. this is not SICP and is not simply a port of the code found in SICP to python with the text unchanged. it's simply a book that seems inspired by SICP but the introduction doesn't go into any detail other than saying it's "derived from" SICP. this is misleading to people who aren't familiar with SICP and think this book is it but just for python.
[+] asicsp|5 years ago|reply
I'm so used to syntax highlighting that it feels odd to try to read code without highlighthing

A bit off-topic, now that legacy.gitbook.com will be read-only from next month, anyone else just giving up on the platform? I used it mainly to allow readers to easily get pdf/epub versions and as far as I know, that won't be possible with new gitbook site.

[+] jxy|5 years ago|reply
I prefer the scheme version, though the addition of 'distributed and parallel computing' chapter is really important and I welcome such new additions.

Unfortunately 'distributed and parallel computing' is no where to be seen in R*RS. I hope we can change that soon.

[+] basucoder|5 years ago|reply
I read interview of Hal Abelson, in that interview he explains the reason behind moving away from scheme to python to teach concepts of SICP.

1. The purpose of course it self has changed, the current course 6.01 in MIT attempts to introduce grads to breadth of the software engineering rather than depths of software engineering. 6.001 course was for the later purpose.

2. He says entire debate is superficial as both the course have different purpose.

It's a lengthy interview.

http://www.gigamonkeys.com/code-quarterly/2011/hal-abelson/

[+] Y_Y|5 years ago|reply
Manual of Ice-Fishing rewritten for desert nomads.
[+] lmilcin|5 years ago|reply
I suppose this will sow even more confusion in young minds trying to figure out their way through programming languages.

Unfortunately, SICP for Python is like an overstretched analogy. It is a joke that only the person that wrote the joke understands and laughs at.

Two decades ago I was doing embedded development in C. I wanted all the nice (at least I thought it was nice back then) that was in C++ but my compiler would not support it. So I started doing it anyway. Yes. You can do it if you want. No. It is not a good idea.

[+] nikofeyn|5 years ago|reply
in the software world, one can avoid the monster that is c++ rather successfully, but it's gotten to the point that no matter what, python is thrust upon you to deal with. "hey here's this thing that is barely working" (in large part because it's written in python) "and we'd like you to maintain it but not switch from python" (because anything besides python makes us uncomfortable). meanwhile, python makes me uncomfortable and is such an unprincipled language, it feels like it fights you every step of the way to write error-free code.
[+] reminddit|5 years ago|reply
Other languages are not as flexible as lisp according to pg. When you get to macros, you might run into limitations with python.
[+] fireattack|5 years ago|reply
Links in each chapter's TOC don't work.
[+] pdamoc|5 years ago|reply
"Do not seek to follow in the footsteps of the wise; seek what they sought." - Basho

One of the reasons that the wizards stopped teaching SICP was the fact that the world changed. Back in the 80s, most programming was done from first principles, since the middle of the 90s it switched to programming against an API.

While learning to program from first principles is still amazingly useful, it is not what beginners need because most of them will never end up programming like that.

[+] ssivark|5 years ago|reply
Love the quote (and totally agree with that), but I'm not sure MIT's decision to teach their freshers on a different track needs to apply to every kind of beginner. Needless to say, there would be a sizeable audience (of whatever background), who would find it extremely useful to learn the ideas in SICP.

All the more because they might not otherwise get the experience of rigorous constructionist thinking, and instead get too used to gluing libraries and slinging boilerplate.

More importantly, for many people, it is an eye-opening spiritual experience where they realize there is more to computing than they previously imagined, and then learn to expect more from their computing tools, and set higher goals for themselves.

[+] randomsearch|5 years ago|reply
I’m not so sure. SICP gives a deep understanding of programming principles like abstraction.

I agree that gluing APIs is essentially what modern programming has become, but it is helpful to have that extra understanding, especially in the long term. We don’t know how programming will look in 2050, but abstraction will remain abstraction, and I wouldn’t bet against Lisp being more popular then than it is now.

[+] craigsmansion|5 years ago|reply
> Back in the 80s, most programming was done from first principles

That's one of the secret revelations in SICP. If you go in with some knowledge of assembly or C, you can quickly feel it's really high-level and not all that fundamental.

That is, until it addresses your precious "fundamental" bits and bytes, and you suddenly realise the model it is showing you is a model you can build computational platforms with, including your up-to-then understanding of registers and ALUs, and it illustrates that computing essentially has nothing to do with any specific hardware: all you need is pencil and paper and the command of a natural language, but with some parenthesis, you can optionally instruct a machine to do it for you as a bonus.

> it is not what beginners need because most of them will never end up programming like that.

which makes any "SICP in X" effort so useless: "let's make SICP understandable for people who do not want to understand it."

[+] jakear|5 years ago|reply
Actually Sussman teaches it to this day (or at least to a couple years ago). I found it one of the most enlightening classes I took.
[+] dang|5 years ago|reply
But they might want to understand.
[+] brlewis|5 years ago|reply
> since the middle of the 90s it switched to programming against an API

Yes, people always seek out libraries rather than using what's built into the language. Browser JavaScript would be a lot more efficient if people took a more SICP-like approach. Also, learning IIFEs would be easier in Scheme syntax.

[+] cc9one|5 years ago|reply
What is an alternative resource that would be applicable to programming against an API?
[+] nromiun|5 years ago|reply
People say SICP is bigger then Scheme and then get outraged when someone implements it in another language.
[+] rfrey|5 years ago|reply
Beethoven is bigger than "piano". Also, there is very little outrage in this thread - some sadness, some resignation, some head shaking sure, but not outrage.
[+] greenshackle2|5 years ago|reply
It doesn't have to be Scheme but I'm skeptical you can do full justice to the metaprogramming parts of SICP if you're not using a homoiconic language.

Unsurprisingly, "SICP in Python" reverts to a Lisp dialect for those parts of the book.

[+] analog31|5 years ago|reply
I don't want to sound snarky, but... is this really it? I haven't looked through SICP itself, and have no formal CS background, but it always seemed like SICP was treated like a forbidding rite of passage. The Python version, if it's faithful to the original, seems pretty lightweight.
[+] wegs|5 years ago|reply
SICP is an designed as a freshman course, and it was designed at a time when many students had never programmed before.

It's worth looking at and trying.

It's an intense course, but it's beautiful, elegant, and you get a lot out of it. I wouldn't call it a forbidding rite of passage by any stretch, though. Given a bit of time and perseverance, anyone can do it, and come out smarter on the other end.

[+] ska|5 years ago|reply
One of the non-obvious things about SICP is that there is a lot of really good stuff in the footnotes and the exercises. You aren't doing yourself any favors if you skim over either of them.