←back to thread

317 points est | 1 comments | | HN request time: 0.321s | source
Show context
KirinDave ◴[] No.17453884[source]
I hope I'm not the only person who reads this and really, really dislikes this.

If Python's gonna have breaking syntax, why not work on bringing it more in line with other modern languages that don't require special breakout syntax for expressions and rely more on functional features?

Are we still maintaining that lambdas are hard but suggesting expression-scoped variables are easy?

replies(3): >>17454262 #>>17454393 #>>17454442 #
kevin_thibedeau ◴[] No.17454442[source]
> Are we still maintaining that lambdas are hard but suggesting expression-scoped variables are easy?

We maintain that list comprehensions do all the things lambdas can without the clunky anonymous functions. All while clearly communicating that a sequence is being transformed without any obscure syntax.

replies(2): >>17454933 #>>17455045 #
nerdwaller ◴[] No.17454933[source]
List comprehensions are more a substitute for map than anything else (which is generally discouraged in the ecosystem). For comparison: `map(lambda x: x * 2, range(10))` vs `[x * 2 for x in range(10)]`.

However lambdas are mostly discouraged because they're often harder to read for anything non-trivial (and really you can't do much non-trivial with them since they are so dwarfed) and you can just define a function in the same block and pass the function reference in place of a lambda. I think the premise is more that it's clearer to pass a clearly named method describing the intent instead of a lambda describing the how.

replies(1): >>17455063 #
KirinDave ◴[] No.17455063[source]
This is an assertion by a Supreme Dictator of the ecosystem. It's not actually backed by any metrics. It not indicated by any stuides. It's not borne out in any data brought to you by teachers. It's actually contradictory to previous findings.

We can also see a migration away from list and object comprehensions in languages that support both them and lambdas (e.g., C#, Haskell).

How the Python community has maintained it's opinion that everyone else is stupid and wrong while also suggesting that their tooling is impossible to understand is beyond me. It seems like a contradictory position.

replies(2): >>17457089 #>>17457095 #
1. nerdwaller ◴[] No.17457089[source]
That's true, though being pretty involved in the ecosystem (e.g. anecdote) I believe that people tend to agree with the general concepts (with exceptions).

> it's opinion that everyone else is stupid and wrong

I can't speak for the BDFL, but I don't believe this is the intent. It's not meant to say everyone else is wrong and Python is right, rather that Python prefers fewer ways to do things and certain complexities aren't worth it when there's a good way already in the language to do $feature. Complexity may not be in the python layer even, it could be maintenance in the underlying implementation (CPython, PyPy, Jython, ...)