Live data from Hacker News

SICP in Python

wizardforcel.gitbooks.io

51–60 of 136 posts

Re: SICP in Python

#51

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.

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 great to not having such things in the language.

Re: SICP in Python

#52
post #39

Earlier quoted context omitted.

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.

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…

[deleted]

Re: SICP in Python

#53
post #8

Earlier quoted context omitted.

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

I see we've reached the point in python's popularity where it is cool to hate it. Happened with C++, Java, Javascript, PHP, and now... Python, of all things. Maybe the least bad of all of those. Like it or not it's here to stay. If Scheme (or whatever language you use) was as popular as python you would think it is bad too since most code out there would be made by amateurs, and its flaws (which all languages have) w…

There is only one thing I dislike about Python, not having JIT support of the box, or in another words PyPy doesn't seem to get the love it deserves.

However after watching several GTC 2020 talks, it seems that at least in what concerns GPGPU programming there are several efforts going on alongside CUDA integration.

Re: SICP in Python

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

Isn’t set builder notation done in the opposite direction at least? Ie given these things which are elements of blah, take these values. In Python it’s reverse, which makes sense in English but is harder to read as a sequence of steps: take these values from this set but only if... Kinda like SQL: select from where

I prefer it as a sequence of steps that get performed one after the other like a pipeline.

Re: SICP in Python

#56
post #30

Earlier quoted context omitted.

If you're looking to learn cool stuff, I highly recommending finding a copy of the original SICP in Scheme and working through it. It will expand your mind to new ideas.

I was going to drop a link to my favorite pdf version (with improved typesetting and graphics), but sadly the download link appears broken :( https://github.com/sarabander/sicp-pdf The web version appears to work though: http://sarabander.github.io/sicp/html/index.xhtml

Yeah it is broken on the master branch but if you change to this one the pdf file is fine: https://github.com/sarabander/sicp-pdf/tree/print

Re: SICP in Python

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

TBH, magic sauce of SICP is Scheme. Even if is using languages other than python (common lisp, go, rust), it will simply miss the point. Idea is that you start with minimal (abstract) language constructs, progress through various problems expanding language on top of those minimal constructs and finalize everything building minimal language on top of that language. You basically metacirulate.

Python (go, rust...) aren't minimal, nor abstract enough to achieve above. For example, most of the SICP problems can be nicely solved in python, but if you are going to add evaluator, you'll need to pull parser/ast modules, which are story on it's own.

Re: SICP in Python

#58
post #41
post #9

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

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

Re: SICP in Python

#59
post #15

"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 nee…

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

Re: SICP in Python

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

> 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. :)

Post reply on HN