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/nevare Nov 11 '08

Python is also my favorite language and what I miss the most from functionnal programming are

  • tail call optimisation (I think I heared people didn't wanted it ... but maybe it was just never implemented ?)

  • more powerfull lambdas

  • implicit return of the last executed line (it makes you feel you are in a functionnal language)

The last two points are solved in ruby, but they didn't implement tail call optimisation either.

1

u/Leonidas_from_XIV Nov 12 '08

I don't like the way how Ruby does it, since the last line is pretty random if the programmer didn't mean to return it explicitly.

1

u/nevare Nov 12 '08

True enough. But I wouldn't mind it if I could write

def f(x): if cond(x): modified(x) else: other(x)

which is pretty how you would write it in Haskell. If you have no side effect there is no need for several lines, so the return is implicit.

1

u/Leonidas_from_XIV Nov 13 '08

I know, this is how it's done in Scheme but it has clearly a more functional approach, whereas Python does rather go the iterative way. Not to mention that explicit is better than implicit in Python.

And yes, I also like the chaining that is possible with jQuery because it consistently returns the changed results.

1

u/nevare Nov 13 '08 edited Nov 13 '08

Yeah this chaining is cool but it is possible with any object programming language. I guess a method returning the objet on which it is when there is no explicit return could help make this a more common thing, but I'm not so sure about this idea.

Anyway you can make jquery in python. I even started doing it.