5 ms·
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 a
by nu11ptr 1y ago
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.
- murkt 1y agoThis 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?
- pansa2 1y agoYeah, Python hasn’t been a simple language for a long time, if ever. That’s probably the biggest misconception about the language - that its friendly syntax implies simple semantics. It’s not true at all.
- tetha 1y agoI would say python in it's entirety is one of, if not the deepest and potentially most complex language I know. C++ is the other contender. The things you could do with metaclasses, multiple inheritance and operator overloading are quite staggering. I'm just glad you don't have to think or even use this as a normal user of the language, most of the time or at all.
- nu11ptr 1y agoThis feature is not complicated, but one must keep every feature that can possibly be seen in code in their head. Even if it is familiar now, what happens when you use the feature in the one small section of code where it fits, nowhere else, and then read that code 2 years later? This is the problem with adding useful features that are only used in a few key places. I'm not saying Go is a perfect language, far from it, but limiting # of features as a general goal is something more languages should strive for IMO.
- kccqzy 1y agoA 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.
- pansa2 1y ago> 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).
- kccqzy 1y agoIf 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__.
- oliwarner 1y agoPython has always been a batteries-included language, so having a go at templated string interpolation —a feature other languages have had for decades— seems like a strange gripe. It's far more essential than little utilities like textwrap or goliath packages like Python's bundled tkinter implementation.
- nu11ptr 1y agoWhat other languages have this feature? I'm not aware of any
- martinky24 1y agoThey literally discuss this in the article.
- pansa2 1y ago> [T-strings] are the pythonic parallel to JavaScript’s tagged templates.
- hocuspocus 1y agoScala since 2014. Java 22 had the feature as preview but it was removed in 23, it'll come back after some refinement.
- thatnerdyguy 1y agoC# has InterpolatedStringHandler which isn't quite the same thing, but (in my understanding), trying to address the same core issues.
- WorldMaker 1y agoC# InterpolatedString is very close, with the twisty bit being that C# can rely on static typing for safety so the "f-string" and "t-string" variants use the same literal syntax and depend on what function they are passed to, whereas in both Python and Javascript they have different literal syntaxes. Python chose to use a different literal prefix to its literals ("f" versus "t") and Javascript chose to use a function-call syntax as prefix (`templateString` versus html`templateString` where html is a function in scope).
- sanderjd 1y agoI'm truly glad that Go exists for people who like languages that are simple even to the point of frustration and I hope it never changes. But I'm glad that other languages exist for those of us for whom learning some syntax is not a barrier and having convenient ways to do common things is highly valued.
- acdha 1y agoThere’s an interesting trade off around maintenance. Python’s stdlib means there’s more consistency across projects and you can assume basic things like error handling which you had to check individually on each Go program, which is the kind of stuff which adds up when you have a lot of small programs. This is especially noticeable with AWS Lambda where you can have a lot of useful stuff running for years without doing more than bumping the runtime version every year or two, but also that is one highly opinionated architecture so it’s not globally optimal for everyone.