3 ms·
It's been about a year or two since I've done anything serious in python, and ... yikes. Does anyone else get the feeling that Python is "C++ing" itself into a
by ajross 18y ago
It's been about a year or two since I've done anything serious in python, and ... yikes. Does anyone else get the feeling that Python is "C++ing" itself into a confusing mess? While lots of these elements weren't surprising to me, some were. And many that were convey little to no real value (c.f. "decorators", or "the step argument in slice operators").
This is the same thing that happened to C++. If you keep adding features that are useful to someone in some specific context, what you get is a more powerful language for an expert user writing code, but one that is much less productive for the people who have to maintain it.
And, can I just ask: how many ways to iterate over stuff does python really need?
- deleted 18y ago[deleted]
- mrtron 18y agoDecorators are greatly valuable. For example, in a framework like Django they are used for permissions in views. So you can quickly just make sure a user is logged in or is an admin to see a specific view, all with an un-obtrusive @login_required. I don't find any of these features bad - they are easy to read and useful.
- shadytrees 18y agoAgreed. The decorator idea didn't just come out of nowhere: It merely codified a convention that appeared in a lot of code where `function` would be defined and then you'd see `function = decorate(function)` afterward. (This is, for example, arguably the core idea of WSGI.)
- ajross 18y agoRight. So ... why bother with adding a feature to the language when the language as it already exists can do it in one easily-comprehended line of six tokens? I'm sure you like the shorter syntax better. But I didn't know it, despite years of experience with scripting languages (and even this paradigm) that should have informed me about what that code means. But it didn't, for the simple reason that it looked funny because I haven't been keeping up with Python. I'll say it one last time: this idea, that the language should cater to its experts by adding features wherever possible, is what has killed C++ as a hacker's language. Python is walking blindly down the same path.
- natrius 18y ago"So ... why bother with adding a feature to the language when the language as it already exists can do it in one easily-comprehended line of six tokens?" The decorator syntax is easier to read. It's at the top of the function where the arguments list and docstring are. Yes, there are tradeoffs when introducing new syntax, but decorators are definitely worth it.
- schtog 18y agois it? python3000 has deleted some unnecessary stuff. i dont really see your concern. it seems gvr is still concerned about the opposite of what you claim.
- lacker 18y agoWell, a lot of these suggestions are the sort of "tricks" that you wouldn't want to use in any normal situation. I think the additions to python are mostly making it cleaner and simpler. List comprehensions are a great example. If you want to reverse the keys and values of a dictionary you can do reversed_dict = dict((value, key) for (key, value) in original_dict.items()) Whereas in c++ this would have to be something like... map<string, string> reversed_dict; for (map<string, string>::iterator it = original_dict.begin(); it != original_dict.end(); ++it) { reversed_dict[it->second] = it->first; } C++ may have added a lot of new stuff but they did not make the simple cases simple, they just made the simple cases possible but still ugly.
- ajross 18y agoYou're comparing the python syntax with the equivalent C++, not with the python syntax it replaced, which by my count is three lines shorter. The point is this: does the savings in code size from a list comprehension (which is 100% pure sugar on top of the existing loop syntax -- there's no new semantics in that feature) balance out the difficulty of teaching them to every new python programmer? If you're a python expert, clearly your answer is "yes! this is a great feature!". But that's what the C++ experts say too, even as their language buries itself under a mountain of complexity. From the outside looking in, I'm seeing exactly the same thing happen to python. Some fancy features make a language fun and productive. Too many such features make it a mess.
- shadytrees 18y agoList comprehensions don't exist in their own vacuum though. For generators (the generalization of list comprehensions) and then coroutines, it's a feature that can't be replicated in Python without serious kludges; it does indeed add semantics. It enables you to do more: threads, actor model, state machine, modularize large functions. I think the cost of implementing list comprehensions was more than worth the while for all the benefits that have been reaped from it.
- anamax 18y ago
- cstejerean 18y agoI wouldn't blame the language for code being hard to maintain. As long as the people doing the maintaing are as competent as the ones that wrote the code to begin with, and the code is well structured, tested and documented there should be no problem maintaining and extending it.
- alexk 18y agoSo, what's your favorite language?
- timmy2shoe9384 18y agoDoes it matter? There all worthless QQ ZIBHACKWAY the question is...... what is your favorite code?