Live data from Hacker News

SICP in Python

wizardforcel.gitbooks.io

71–80 of 136 posts

Re: SICP in Python

#71
post #58
post #41

Earlier quoted context omitted.

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

This almost made me fell off my chair. 5:5 And, behold, I will deliver you up to the programmer tendency to build overelaborate castles of abstractions

One person's overelaborate is another's perfection.

Behold! The abstraction in ethereal splendor makes mundane human existence bearable!

Re: SICP in Python

#72

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…

Maybe 90% of Python programmers fail to answer that question until they actually try to do it. Then they never forget.

Re: SICP in Python

#73
post #67

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…

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?

TIL: https://docs.python-guide.org/writing/gotchas/

Re: SICP in Python

#74

Earlier quoted context omitted.

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.

But why is the course “all about classes, getters and setters, inheritance and so on”? It sounds like a Java class before the language is even chosen. No wonder the best choice ends up being Java.

When I took CS in school, these were not the central themes. On the last day of class the teacher showed us a short program in this funky new language called “Java” and we all had a good laugh at how it tried to make everything about objects, even where it made no sense.

Even if you’re only trying to teach object-oriented programming, I can think of better languages.

Re: SICP in Python

#75
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…

Unlike most programming books the environment and code samples never go out of date either. It's entirely self contained including assembly language.

Re: SICP in Python

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

Re: SICP in Python

#78
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…

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.

Re: SICP in Python

#79
post #48
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…

map(lambda x:x^2, filter(lambda x:x%6==0, map(lambda x: x*2, getNumbers()))) Would probably be a more pythonic way to do that, avoiding list comprehensions. Easier to read with added lines and indentation. But tbf I do appreciate the ability to chain operations in JS without subclassing objects like list.

You’re saying it’d be more Pythonic to not use list comprehensions? I find that doubtful.

Re: SICP in Python

#80

Earlier quoted context omitted.

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.

Dijkstra once said: "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."

I find much the same to often be true for many Java programmers. Programmers who start out with a course all about classes, getters and setters, inheritance and so on often end up with their minds wedged such that they never learn to program properly.

Java has one way to do everything. That's reasonable if you're running a large IT department and want programmers to be interchangeable between projects. That's a horrible way to have people understand the richness of computation.

You want new students to learn at least two ways to do abstraction and to structure code, and ideally, to learn many. Then, if they do Java for a random bank or something, they'll see where Java is on the spectrum. If you start with Java, you end with a closed mind.

Post reply on HN