The fate of reduce() in Python 3000

Link

Guido van Rossum comments on the elimination of map(), filter(), reduce() and lambda from Python 3000:

About 12 years ago, Python aquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches. But, despite of the PR value, I think these features should be cut from Python 3000.

He believes map and filter are unnecessary because there are list comprehensions. But what about reduce ? It seems Guido doesn't believe in folds:

So now reduce(). This is actually the one I've always hated most, because, apart from a few examples involving + or *, almost every time I see a reduce() call with a non-trivial function argument, I need to grab pen and paper to diagram what's actually being fed into that function before I understand what the reduce() is supposed to do. So in my mind, the applicability of reduce() is pretty much limited to associative operators, and in all other cases it's better to write out the accumulation loop explicitly.

And then, with these functions gone, there is no use for lambdas, he argues.

I find it positive, in general, when designers eliminate features from a programming languages, if they are rarely used, but maybe he is being too harsh on reduce(); it may be my predilection for functional programming getting on the way, though.

via PLNews

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

If you don't like Guido's direction, don't use Python.

Or fork it. Or use Scheme or Ruby or Perl or JavaScript or something else.

I'm not defending Guido at all--fold/reduce is such a fundamental thing that ought to be in the language somewhere (if nothing else, in the library). I suspect that if Py3k doesn't provide it, numerous application and library developers will provide their own versions (which, naturally, won't work in the same fashion, etc.)

But...

One interesting phenomenon I've long observed is that many programmers think that every language should be like their favorite. Many complaints about C++, especially early ones, seem to be of the form "it's not Smalltalk". Now there are lots of things about C++ which annoy me, but the fact that it's not a dynamically-typed "pure" OO langauge isn't among them.

Bjarne Stroustrup famously quipped "If you want Smalltalk, you know where to find it."

Likewise with the present situation. If you want Haskell, or Scheme, or ML--those are all easily available. Python serves a niche, and serves it well. Like anything, if it fails to continue serving the niche, it risks being replaced.

And I suspect that removal of "reduce" from the language will impair it's ability somewhat.