Live data from Hacker News

SICP in Python

wizardforcel.gitbooks.io

61–70 of 136 posts

Re: SICP in Python

#62
post #54

People say SICP is bigger then Scheme and then get outraged when someone implements it in another language.

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.

Re: SICP in Python

#63
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/

Re: SICP in Python

#64
post #50

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…

NB: That is actually the second edition from 1996.

Re: SICP in Python

#65

Earlier quoted context omitted.

The vast ecosystem of python libraries is an incredibly powerful argument for using it. One major library could dramatically cut the development time of your project. You’ve not spelt out actual reasons why Python is so bad, could you give your top three?

One thing I have felt is that python doesn't embrace the functional way of thinking, even to the extent that JavaScript does. I personally find that once I have been exposed to a modern functional approach like in Clojure, etc, I find python lacking. Not just syntactically, but conceptually. For example, IIRC, many list methods in python modify the list they are working on, instead of returning a new list.

Quick example off the top of my head is the built-in sorted function. That returns a new list if I'm not mistaken.

Re: SICP in Python

#66
post #7

Earlier quoted context omitted.

I concur, this book is a terrible way to introduce anybody to Python. I imagine they want to teach general programming skills, and hence want to give you a "way to think" that is low level enough to let you work with any language, using Python as a pseudo-code to demonstrate it. This approach is doomed to fail. It's much better to teach the language properly, then introduce other languages as a comparison point, if t…

SICP shouldn't really be taught in any language other than Scheme, or a language designed specifically for teaching SICP. It doesn't make sense otherwise.

It could probably work in an ML variant like SML.

Re: SICP in Python

#67

Earlier quoted context omitted.

SICP is about deeply understanding computation. Scheme is a good language for SICP because it's simple. You can build a Scheme interpreter as a class project. You can analyze it formally. Etc. Python is a good language because it's readable and writeable. But it doesn't work for SICP since it's too complex for that. Python also intentionally omits things critical to SICP (like tail recursion). Calling this book "SICP…

Except that 90% of Python programmers fail to answer simple questions like: Given: def extendList(val, list=[]): list.append(val) return list What do the following print: print(extendList(1)) print(extendList(1)) print(extendList(2)) print(extendList(3,[])) I do not blame them. This sort of behavior is error-prone. You can make sure that you do not use such a code in production with code reviews but it would be also…

For what it’s worth, I’m not a Python programmer and I got that correct.

The answer is:

[1]

[1, 1]

[1, 1, 2]

[3]

It relies on knowing something about how python applies default arguments.

I’ve only written about a hundred lines of python in my life, so possibly I just got lucky - still, I would have thought an actual Python programmer should get this?

Re: SICP in Python

#68
post #25

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 enter…

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.

This relates heavily to the "what language should be taught in schools" argument. I usually answer "Java". And it's not even that I particularly like Java, it's just that the discussion often neglects that the course involved is all about classes, getters and setters, inheritance and so on. It's nonsense to shoehorn this into many other languages.

Re: SICP in Python

#69
post #41
post #9

Next it will be SICP for Java. Is nothing sacred?

Concerning "sacred": https://kingjamesprogramming.tumblr.com/

"Investigate the shell’s here documents and Python’s triple-quote construct to find out the Almighty unto perfection"

Now I won't sleep tonight.

Re: SICP in Python

#70

Earlier quoted context omitted.

SICP is about deeply understanding computation. Scheme is a good language for SICP because it's simple. You can build a Scheme interpreter as a class project. You can analyze it formally. Etc. Python is a good language because it's readable and writeable. But it doesn't work for SICP since it's too complex for that. Python also intentionally omits things critical to SICP (like tail recursion). Calling this book "SICP…

Except that 90% of Python programmers fail to answer simple questions like: Given: def extendList(val, list=[]): list.append(val) return list What do the following print: print(extendList(1)) print(extendList(1)) print(extendList(2)) print(extendList(3,[])) I do not blame them. This sort of behavior is error-prone. You can make sure that you do not use such a code in production with code reviews but it would be also…

are those statements executed one after the other? In any case, it's definitely a pitfall, one that has been fairly widely publicised, even with checks embedded into various tools/IDEs.
Post reply on HN