Comment by wheaties
3 years ago
This is why adding language features needs to be carefully thought out and explored to great lengths. Sadly C++ never got that memo. Here's hoping Python remains "simple."
3 years ago
This is why adding language features needs to be carefully thought out and explored to great lengths. Sadly C++ never got that memo. Here's hoping Python remains "simple."
I’m not sure I understand the “this is why” part. Python wants to let you override almost everything. It’s a feature and a powerful and occasionally helpful one. It’s also a feature you never ever have to know about or touch.
This debate could be summed up as:
There's more than one way to do it *vs* there should be one, and preferably only one, obvious way to do it
> there should be one, and preferably only one, obvious way to do it
Loops, list/dict comprehensions, if statements, and ternary expressions would all like a word
1 reply →
Agreed - I mostly use Python for small scripts and it makes that use case very easy. I know it has a bunch more features for more niche stuff as well but my throwaway script to download images from a webpage doesn't need pattern matching.
It's like python's metaclasses. You rarely need them but sometimes they really are just the best solution to the problem. Those times, you're really glad they're available.
> It’s also a feature you never ever have to know about or touch.
The "never have to know or touch" argument applies only to the lone hacker working on a completely new project with no inherited legacy code.
Indeed. Most Python code bases I have seen are maxing out all obscure features like those in the article. In practice, Python today is one of the most unreadable languages in existence.
It’s quite clear from the design of Python, both of recent features and of fundamentals like `+=`, that its designers never got that memo either.
I’m baffled as to how it retains its reputation of being a simple language.
I think it’s a pretty simple language for how powerful it is. But it’s not simple compared to some other languages like Go
Wait, what's the deal with `+=` ?
`a += b` sometimes does the same thing as `a = a + b`:
Sometimes it does something different:
IMO if that behaviour had been "carefully thought out" by the language designers, it should have been obvious that it's a bad idea.
Failing that, the implementation of that behaviour is convoluted - so the designers should have paid attention to the Zen of Python: "If the implementation is hard to explain, it's a bad idea".
Failing that, if the behaviour had been "explored to great lengths", the designers would have understood how it interacts with other language features - in particular, nested mutable and immutable objects.
Python's designers failed to do any of these things, so we've ended up with an operator with unpredictable behaviour and a long FAQ entry [0] about how its possible for an operator to both succeed and fail at the same time:
[0] https://docs.python.org/3/faq/programming.html#why-does-a-tu...
It can mean two completely different things. `let x = x + 1` (rebinding) or `x += 1` (mutation).
The obvious x = x + y and the also-works x += y. There is more than one way to do the operation. The conceptually more simple way would be the former as it does not require the programmer to know an extra operator.
I like Python, but it really isn’t “simple” (at least not for more than a decade).
Is it better for Python to be simple than for Python to be simple for simple problems?
All languages got the memo, including C++.
Either you get Scheme, or languages with features.
Even C isnt' as "simple" as people take it to be.