←back to thread

620 points tambourine_man | 3 comments | | HN request time: 0.694s | source
Show context
nu11ptr ◴[] No.43750542[source]
Personally, this feels like a feature that is too focused on one problem to be a general feature. Python is getting huge. When people ask me if Python is easy and simple to learn I have to say "the basics, yes, but to to learn the whole language... not so much".

I feel like in this sense Go really is interesting by rejecting almost every single feature. Honestly not sure generics were worth it as they add a lot of complexity, and while they are nice, I don't need them very much. The general idea to keep the language at its original focus is the right idea IMO. C++ would be the most extreme case where the language itself barely resembles what it started out as.

replies(4): >>43750633 #>>43750807 #>>43751386 #>>43754916 #
murkt ◴[] No.43750633[source]
This is a pretty simple and useful feature. I wouldn’t say that it bloats the language too much. Descriptors and metaclasses are much more complicated and have a lot more implications and have been in the language for a veeeeery long time. Is it decades already?
replies(3): >>43750700 #>>43752735 #>>43766039 #
1. kccqzy ◴[] No.43766039[source]
A lot of Python's complexity like descriptors and metaclasses and the so-called cooperative multiple inheritance come from an era where object orientation is gospel and yet people keep finding limitations to what can be accomplished in an OO paradigm and therefore they patch up the language to support ever more complicated use cases.

I have a feeling that if metaclasses and descriptors were to be proposed today it would be laughed out of the PEP process completely.

replies(1): >>43767213 #
2. pansa2 ◴[] No.43767213[source]
> I have a feeling that if metaclasses and descriptors were to be proposed today it would be laughed out of the PEP process completely.

I think you need at least one of these. Modern Python eschews metaclasses but descriptors are everywhere. Without them you couldn’t have @classmethod, @staticmethod nor @property - or at least, you couldn’t generalise custom method lookup and all three of those would need to be special cases.

The alternative approach is to drop descriptors and make method lookup much simpler, but then you need metaclasses (see: static methods in Ruby).

replies(1): >>43767556 #
3. kccqzy ◴[] No.43767556[source]
If descriptors didn't exist in the language, classmethod, staticmethod, and property would become keywords. Languages like Java and C++ already have static as a keyword; C++ also made its type system have a special pointer to member type; such behavior can be hardcoded without having a flexible descriptor mechanism.

Custom method lookup would just be the same as custom attributes, that is, by the user overriding __getattr__.