4 ms·
You complain that Python has acquired bloat in the past decade, and appear to be citing the presence of tuples, dicts, and lists as an example of this. Since t
by neild 16y ago
You complain that Python has acquired bloat in the past decade, and appear to be citing the presence of tuples, dicts, and lists as an example of this. Since tuples, dicts, and lists have existed in Python for well over a decade, I don't quite see how they can be an example of acquired bloat.
As for decorators...well.
@dec
def somefunc():
pass
is almost precisely identical to
def somefunc():
pass
somefunc = dec(somefunc)
In other words, decorators are pure syntactic sugar. I suppose you could call that "bloat", although I'd rather strongly disagree. There's nothing at all wrong with making common patterns easier to write, and I've written plenty of code which has benefited from access to decorators.
What really puzzles me is that it seems that what you really want is simply added syntax for multi-line anonymous functions...in other words, syntactic sugar. I suppose that "bloat" is any sugar that doesn't come in your preferred flavor.
- silentbicycle 16y agoMy complaint mixed two things - one, I'm not convinced that decorators are a special-case "feature" that would come for free with better lambdas. Two, does Python need tuples, dicts, AND lists? (I know it's had them for a long time.) Python seemed really refreshingly clean compared to Perl and C++, the languages I'd been using previously. I still think it's a decent language, but Python is to Perl and Lua is to Python along those lines. I've moved on. I'm probably still just annoyed about Guido's position on tail-call optimization, though.
- wyuenho 16y agoPython's lambda is not broken, it's just that the notion of a (progn) from Lisp doesn't exist in Python, so Python's lambda is a lot harder to use because for anything more complicated then 1 expression, you'd have to define a fully named function somewhere. For the most part this isn't an issue because you probably wouldn't want to have more then 2 or 3 expressions in a lambda anyway. Granted, a lot of languages like Ruby, Lua, ML and even CoffeeScript have arguably even cleaner syntax then Python, but none has as vast a community and quality libraries that mirror Python. In choosing a language, the language itself matters, but the ecosystem equally matters IMHO.
- vog 16y ago> Granted, a lot of languages like Ruby, Lua, ML and even CoffeeScript have arguably even cleaner syntax then Python But Python has still the cleanest standard API. At least for me, that's what made me switch from Ruby to Python in the past.
- silentbicycle 16y agoThey're also much cleaner in languages with expression-oriented rather than statement-oriented semantics -- languages where the result of a function is implicitly the last value in it, without needing a return statement.
- gaius 16y agoBut you can nest function definitions, so in practice the lack of a multi line lambda just means just prior to where you use it you'd just have a "def f ...".
- vog 16y ago> Two, does Python need tuples, dicts, AND lists? While I agree that tuples and lists could be merged, I don't think that dicts should be merges with them, too. When I first looked at PHP I found the concept of having a unified "array" type (for arrays and hash tables) very clever. However, I quickly changed my mind. Now I think that the array/hash unification is one of the biggest design mistakes in PHP as it provides no benefit (both have completely different use cases), but causes a lot of trouble. A similar argument goes for ECMA Script (aka JavaScript).
- silentbicycle 16y agoIt seems to work well for Lua, though it has an explicit optimization so that dicts with consecutive integer keys are automatically stored internally as an array.
- viraptor 16y ago> does Python need tuples, dicts, AND lists? Pretty much yes. dicts are something completely separate from list-like types. Those should not be mixed. lists and tuples depend on your preference really, but I appreciate them being available. There are many places where you want to pass an immutable sequence of objects and the list is just not right... Sure we could get rid of them, but what would be the gain there?
- techbio 16y agoGenerally I will use lists for fast and loose vectors, in unoptimized code, and tuples for more firmly "typed" data, or performance enhancements. I don't need more and I don't need less: the two seem well-balanced for me. As someone who abhorred Perl, Ruby looks a little frightening. Python looks and feels clean, especially for blocks of data. In OO though, self.whatever appears more frequently than I'd like.