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.

2

u/aieee Nov 11 '08 edited Nov 11 '08

"Hostility to functional programming is a form of hostility to abstraction, theoretical correctness and cleanliness"

I don't think the community or the BDFL are hostile to these things, more generally conservate and hostile to certain coding styles.

The Python way is to prefer easy digestability over things like proper lambdas, and reduce. Lambda is crippled to stop people writing ugly code. Reading the occasional blog post with ugly Ruby code makes it easier to understand why this choice was made.

I would personally prefer more support for functional programming, but I sort of understand the logic of not accepting functional features without carefully judging the trade-offs with the 'pythonic' way.

-1

u/Wiseman1024 Nov 11 '08

I don't think the community or the BDFL are hostile to these things, more generally conservate and hostile to certain coding styles.

Which is exactly what I've said.

Lambda is crippled to stop people writing ugly code.

Okay. Then let's cripple classes, inheritance, operator overloading, if-elif sequences, list comprehensions, regular expressions, string manipulation, template languages, and pretty much everything too.

5

u/aieee Nov 12 '08 edited Nov 12 '08

Which is exactly what I've said.

To be clear, I'm saying they're not hostile to "abstraction, theoretical correctness and cleanliness" per se, but the possibility of features enabling those things leading to unpythonic code.

Okay. Then let's cripple...

I'd prefer proper lambdas, but if I kinda squint, I can see Guido's logic in forbidding them, since named functions accomplish the same thing.

To make the distinction clear, though perhaps it is a small distinction: Python is not especially hostile to functional ideas - but it is hostile to the kind of hard-to-decifer code that the functional style can produce, especially if there is a fairly straightforward alternative.

Again, I'd like Python to be more functional for certain situations, and is the reason I'm sniffing around other languages. But I think 'hatred' is far too strong a word to describe the Python attitude to functional programming.

In this light, Guido's rational for removing reduce seems reasonable (though arguable), "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" http://www.artima.com/weblogs/viewpost.jsp?thread=98196

Edit: on further reflection, and reading your other replies, I pretty much agree with you. The fear of introducing functional concepts in the python community is exaggerated. However, this natural conservatism may be part of what has made Python the otherwise great language and community it generally is.

1

u/Wiseman1024 Nov 12 '08

I'd prefer proper lambdas, but if I kinda squint, I can see Guido's logic in forbidding them, since named functions accomplish the same thing.

Then let's forbid strings, since array.array('c') accomplish the same thing.

Python is not especially hostile to functional ideas - but it is hostile to the kind of hard-to-decifer code that the functional style can produce

I don't find tail-recursive functions, nested lambdas, reductions, etc. hard to decipher, definitely not harder to decipher than imperative loops with several variables. I think it's just prejudice against the unknown, and since people come from the damned Fortran line... Maybe there's a similar amount of prejudice against while loops from people who come from Scheme.

"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"

I think/hope it's an hyperbole of his; in other words I can't believe it. I regard Guido as smarter and more experienced than I am (albeit a FP hater ;) ), and I don't need paper to understand reductions.

1

u/[deleted] Nov 12 '08

Frankly, if you're writing a lot of one-time use functions in python, you're not writing python correctly.

1

u/[deleted] Nov 12 '08

Seriously grumpy, you need to find a new language. Who has the gun to your head?

I realize you are a troll, I should not even be responding to you. . .