[HN Gopher] Python as a Second Language Empathy
___________________________________________________________________
Python as a Second Language Empathy
Author : luu
Score : 12 points
Date : 2025-02-27 05:46 UTC (2 days ago)
(HTM) web link (ballingt.com)
(TXT) w3m dump (ballingt.com)
| zahlman wrote:
| > Who here has another language that they knew pretty well before
| learning Python? (most hands go up) Great! Terrific! That's a
| superpower you have that I can never have. I can never unlearn
| Python, become fluent in another language, and then learn Python
| again. You have this perspective that I can't have.
|
| It felt a little strange to read this. I knew many languages
| "pretty well" (or would have said so at the time) before Python,
| but it's been my primary programming language pretty much the
| entire time since I first picked it up 20 years ago. So I do have
| that perspective (I also spend a fair amount of time thinking
| about PL design in the abstract), but I don't feel "PSL" at all.
|
| > Does the value stored in `a` know the name of that variable?
|
| Okay, I'm stumped - in what other language _would_ it "know" (I
| assume this means automatically recording the string "a" as part
| of the object's state in some way)? Or is this just referring to
| debugging information added in some environments?
|
| > Python = is like Java, it's always a reference and never a copy
| (which it is by default in C++).
|
| Java has primitive types, for which it is a copy. But it's more
| accurate IMO to attribute this as a property _of names_ , rather
| than a property of assignment. Python's names (and most Java
| values, and some C# values) have reference _semantics_. Having
| understood that properly, saying that Python (like Java) is
| "pass by assignment" then just follows naturally, and all the
| usual confusion around this point vanishes. Passing an argument
| to a function is simply assigning it to the corresponding
| parameter. (C++'s idea of "references" _in the type system_ is
| far more complex IMO - e.g.
| https://langdev.stackexchange.com/q/3798/_/3807#3807 .)
|
| > We have both reference counting and garbage collection in
| Python.
|
| This is strange phrasing, because reference counting is a garbage
| collection strategy. I assume that here "garbage collection" is
| meant to refer to mark-and-sweep etc. strategies that operate in
| a separate pass, timed independently of the explicit code. But
| also, the reference-counting system is a CPython implementation
| detail. (Although it does look like PyPy tries to emulate that,
| at least:
| https://doc.pypy.org/en/default/discussion/rawrefcount.html )
|
| > I'll translate this one to the transcript later - for now
| you'll have to watch it because the visual is important: explicit
| super.
|
| Raymond Hettinger's video is also a useful reference here:
| https://www.youtube.com/watch?v=EiOglTERPEo
|
| > It takes less characters in Python!
|
| This checks out, but it would be fairer to show what it looks
| like on the declaration side rather than just the usage side.
| ForTheKidz wrote:
| > This is strange phrasing, because reference counting is a
| garbage collection strategy.
|
| Oof, don't open that can of worms. Let me summarize the result:
| 1) the distinction is arbitrary and 2) people are very
| passionate about their personal view being considered
| canonically correct. To the extent i've started referred to
| refer to both mark-and-sweep/boehm garbage collection and
| reference counting as "automatic memory management".
| daveguy wrote:
| Title needs (2018). Data on language usage growth goes to 2018.
___________________________________________________________________
(page generated 2025-03-01 23:00 UTC)