Live data from Hacker News

SICP in Python

wizardforcel.gitbooks.io

81–90 of 136 posts

Re: SICP in Python

#81

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.

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.

Re: SICP in Python

#83
post #81

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.

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.

Thanks. I can certainly appreciate that aspect, and reading it is on my bucket list. I think I'll still read the old version.

Re: SICP in Python

#84

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…

If this is a problem for you, I recommend pylint. No need to rely on code reviews, and catches majority of cases like this.

(You’ll likely want to disable some of the more opinionated checks, but this is well documented and supported)

Re: SICP in Python

#85
As someone who has taken this iteration of the course and read most of the original SICP, I actually think this new CS61A does a really good job of covering the same material as the original SICP while introducing beginners to a useful rather than esoteric language. The capstone project is still writing a scheme interpreter, just in Python. We still do actually write some code in Scheme, just in the later portion of the class.

Re: SICP in Python

#86
post #49
post #39

Earlier quoted context omitted.

In line with this, list comprehensions are one area of python I find particularly clunky. They work fairly well for a single map or filter operation, alright for both mapping and filtering, and are absolutely unreadable for anything more complicated. A big part of this in my opinion is how they scramble the flow. Instead of taking a piece of data and performing successive operations on it, both in logic and in syntax…

Python’s list comprehension syntax is based on the set-builder notation from mathematics. However, I think it would have been better to break with tradition and use a different order, one which matches the order of the equivalent nested loops: flattened_list = [for x in list_of_lists: for y in x: y] This is essentially the same re-arrangement that was made in C#‘s LINQ: it uses from-where-select instead of SQL’s sele…

This looks nice for this case but I don’t think filter would work properly. JS is much more similar to Linq and people seem to love linq. I don’t know of anyone else that does it like python, but plenty do it like JS. For me that tells you all you need to know about whether it’s actually a good idea.

Edit: SQL does it a bit like python and it’s a massive pain in my opinion (and the opinions of many others I’ve talked to). Msft agreed so they made Kusto which does it like JS and everyone I’ve spoken with vastly prefers it.

(Work at msft, no info on the actual business reasons behind kusto, etc etc.)

Re: SICP in Python

#88
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.

[deleted]

Re: SICP in Python

#89
post #81

Earlier quoted context omitted.

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.

Thanks. I can certainly appreciate that aspect, and reading it is on my bucket list. I think I'll still read the old version.

Nah. You'll definitely want the new version. I'm not exactly sure what changes were made between the 1st edition and the new 2nd edition, but the 2nd edition is canonical.

The text is online:

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

Virtually all Scheme interpreters support it:

https://docs.racket-lang.org/sicp-manual/index.html

https://www.gnu.org/software/mit-scheme/

Assignments and video lectures are on-line:

https://ocw.mit.edu/courses/electrical-engineering-and-compu...

And so on. There's an ecosystem around it.

I think the only reason to go with the old version is for historical interest.

Re: SICP in Python

#90
post #70

Earlier quoted context omitted.

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.

Why didn't the Python developers use the possibility of introducing backward-breaking changes in Python 3 to fix such a pitfall?!
Post reply on HN