r/Python • • Nov 11 '08

Why the hatred for functional programming?

0 Upvotes

86 comments sorted by

View all comments

5

u/Wiseman1024 Nov 11 '08 edited Nov 11 '08

Okay, I don't think I need to tell why I'm asking this. While Python supports functional programming to a reasonable extent, there's a widespread stubborn hatred of functional programming and anything related to it in the Python community (probably starting with the BDFL), and any proposals for extending Python into something more useful for functional programming (without taking out any of the other ways to use Python, of course, that's the good thing about multi-paradigm languages) is received with ruthless hostility and perceived as an attack against Python.

The Python community is generally a good one (especially compared to others), yet this generalized hatred for functional programming and anything related to it seriously turns me off. While Python is currently my overall favourite programming language (considering the quality of the standard and non-standard libraries, support, and features), I'm currently considering putting my effort and time investments somewhere less hostile to functional programming.

Hostility to functional programming is a form of hostility to abstraction, theoretical correctness and cleanliness. I hope I'm wrong, but this seems like pulling the PHP way. Consistently meeting proposals such as tail call elimination with nothing short of "that's liek difficult to understand d00d ha ha no freaking way" doesn't say much about the health of this community; in fact it looks like something straight out of the average PHP documentation comment.

3

u/cc81 Nov 11 '08
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

6

u/kinghajj Nov 11 '08

Beautiful is better than ugly. Simple is better than complex. Flat is better than nested. Readability counts. If the implementation is easy to explain, it may be a good idea.

And functional programming helps with all of these goals, especially if (gasp) you optimize tail calls! Recursion is beautiful.

2

u/Wiseman1024 Nov 11 '08

I know, the Zen of Python.

Beautiful is better than ugly.

Yay, an argument for functional programming.

Explicit is better than implicit.

Yay, an argument against Perl.

Simple is better than complex. Complex is better than complicated.

Yay, unless Guido thinks Fortran is simple and Scheme is complex. If so, I suggest he tries assembly, he'll find it the simplest language ever.

Flat is better than nested.

Bingo. This is a fundamental flaw of Python's philosophy. This is so wrong I don't know where to start. This is an argument against abstraction, against flexibility, against expressivity, and against anything that's good in a programming language. I'm starting to think I should take my previous suggestion seriously, and write Python about the wonderful language assembly which has no nestable elements.

Sparse is better than dense.

More arguments against Perl.

Readability counts.

An argument for functional programming and nesting without requiring you to jump when reading code.

Special cases aren't special enough to break the rules.

Okay, at least he got this right: he doesn't want Perl.

Although practicality beats purity.

Meh. Only to a certain minimal extent. And it's disgusting and shameful when it does. It shouldn't be written here, it may spoil people.

Errors should never pass silently.

Yes, please.

Unless explicitly silenced.

You mean, like PHP's @ ? (j/k)

In the face of ambiguity, refuse the temptation to guess.

Of course. I think I fully agree with Python's syntax philosophy (except for the little bit where less powerful cousins of expressions exist for no reason, serving only as a left-handed hammer since you already had expressions and they were much better).

There should be one-- and preferably only one --obvious way to do it.

I used to think this is a good idea, but I'm seeing it leads to "Pythonic", and "Pythonic" leads to a sub-optimal language.

Although that way may not be obvious at first unless you're Dutch.

I'm not worried if it's not obvious. I'm worried that it's not good.

Now is better than never. Although never is often better than right now.

Agreed.

If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea.

Yes! And if the explanation is the implementation, you've achieved Satori. In other words, you're programming functionally. Now let's pay proper attention to FP, please.

Namespaces are one honking great idea -- let's do more of those!

Yes, but don't lose the focus: it's lexical closures the number one honking great idea.