Live data from Hacker News

SICP in Python

wizardforcel.gitbooks.io

91–100 of 136 posts

Re: SICP in Python

#91
post #89

Earlier quoted context omitted.

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

>>> The text is online:

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

There goes my next few weeks.

Re: SICP in Python

#92

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.

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.

Re: SICP in Python

#93

Earlier quoted context omitted.

i personally can't get past it. i've hated every second of developing in python in my jobs, and i just sit there wondering how nice it would be if i could move off of it, especially when debugging and finding yet another inane design decision in python or something that doesn't work. there's never been a reason to use it other than that's what someone unfamiliar with better choices chose for the project, and there's…

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?

> The vast ecosystem of python libraries is an incredibly powerful argument for using it.

vast ecosystems exist in other languages as well. python is not magically the only language that has libraries. in my experience, python libraries exist but aren't great and lead to issues. also in my experience, .net libraries often exist alongside the python libraries, and in many cases companies often provide C/C++ DLLs or .NET assemblies more often than Python APIs.

> One major library could dramatically cut the development time of your project.

in my experience, the half-baked nature of python libraries actually increased development time.

> You’ve not spelt out actual reasons why Python is so bad, could you give your top three?

thanks for asking this rather than indiscriminately downvoting. my reasons are:

* the module system is a mess and can hardly be called a system. anything greater than a few scripts and modules becomes a mess, whereas other languages have much better module and project systems (the latter of which python doesn't even have). the module system in python is little more than a hack just barely exceeding file path linking.

* pip is a mess.

* the python 2 vs 3 issue is trivialized by people, but it is anything but trivial in practice. the first python codebase i worked against was using an internal tool at a large company. they were actually using python 2.6, and it was me, a new user, who pushed them to use 2.7 (which didn't happen before i left). the next system i worked on was also using 2.6 at another company, and i upgraded them to 2.7. the installation procedure for the python packages was a mess (see the module system and pip being a mess). upgrading them to python 3 was a non-starter and on further projects, they ignored my suggestions to them (i wasn't working on the system) to upgrade to python 3 because they didn't see the reason to. next system was also in python 2.7, and due to package obsolescence and deprecation and version jumps, the entire codebase basically required being rewritten in python 3 and newer packages.

* the ecosystem isn't as complete or robust as people imply. even python's built-in XML parsing library has many issues and lack of features, and i have even seen differing behavior between linux and windows.

* python the language is most simply described as unprincipled. there are surprises and gotchas everywhere. for example, the following generates a run-time error:

  def now():
    return "now"

  def usage():
    now = now()
    return now + "!"
the error is "UnboundLocalError: local variable 'now' referenced before assignment". now do the same in f# or racket or any other sane language in which expressions return values which are then bound sanely to identifiers. python is full of stuff like this. if you've used more sanely defined languages, coming to python is actually quite complicated because it is so unprincipled. it does not have a small core base layer that allows for predictable code.

* python has no consistent way to write asynchronous or concurrent code and has major limitations on whether the code you write is actually concurrent. i've done a lot of concurrent code. when i learned elixir/erlang, it was so easy to understand (many python people probably consider elixir/erlang to be more complicated than python), but when i tried to learn asyncio in python, it felt very complicated. there are tons of caveats right off the bat, and it is completely different than other ways of writing concurrent programs in python.

Re: SICP in Python

#94
post #65

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.

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

What I had in mind was the append function, it modifies the list instead of creating a new list.

Re: SICP in Python

#95
post #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/

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.

Re: SICP in Python

#96
post #28
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…

As a Python programmer, it would be interesting to hear why you thing Python in unprincipled? I haven't felt that myself so curious to see what your thoughts are.

Not the person you replied to, I don't hate Python, it's not my favorite but it's my most used language.

Python is unprincipled in its design. It's a kitchen sink language. It has principles (PEP 20) but they explicitly eschew purity of design in favor of practicality, readability, and simplicity of implementation.

Python's type system is very flexible. You may see that as a plus, to me it feels all over the place. It has classes which you can turn into half-baked nominal typing with type annotations. You can mix-and-match interface inheritance and implementation inheritance with multiple inheritance.

You can do unholy things to the class system with metaclasses and the issubclass hook. I have seen it, in a half-million LOC project.

It has protocols, which are duck typing, which you can turn into half-baked structural typing with type annotations.

It is multi-paradigm and it's acceptable at all but not the best at any. If you want strictly OOP or functional you're better served elsewhere.

You can mix-and-match type systems and paradigms in a single codebase, which can be useful, but it's up to dev discipline to not turn the codebase into a horrible mishmash.

In comparison, I don't like writing Java, but I have to admit it limits the amount of damage undisciplined devs can do to a project.

Re: SICP in Python

#97
post #54

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

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.

Re: SICP in Python

#98
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?

It is different from how Ruby and Javascript handle default arguments. I'm surprised Python does that, since I would expect function arguments to be reset to their defaults each call. That's a major side effect.

Re: SICP in Python

#99

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…

[deleted]

Re: SICP in Python

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

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.
Post reply on HN