r/functionalprogramming • u/aurreco • Oct 27 '21
Question What are the downsides to functional programming?
Hello,
Recently I’ve gotten pretty used to programming functionally from my CS class at school. Decoupling state from functionality is really appealing to me, and the treating a program like one big function is great too.
So my question is this: is there any reason why this way of programming isn’t the industry standard? What are the benefits of iteration over recursion? Why are mutable variables valued? Basically, why is it so niche when it feels like it should be a mainstream programming philosophy?
48
Upvotes
View all comments
Show parent comment
10
u/ws-ilazki Oct 27 '21
I think Python's popularity is indicative of the cognitive dissonance of wanting to be performance-obsessed but not wanting to deal with the reality of it.
Whenever Python's shoddy performance is mentioned, almost nobody goes "sure, but the convenience outweighs that; we don't actually need the performance for most things." No, the response is more likely to be something along the lines of "it doesn't have to be fast because you can call C code, so just write the slow parts there!" Which is an attempt to sidestep and ignore the fact that yes, Python is still slow, and writing C doesn't actually fix or remove that problem in any meaningful way because any language can do that. Also, that code doesn't just magically appear; someone still has to write the C code and make the bindings, but they hope it'll be someone else so they can continue writing their slow Python library glue while enjoying the benefits of someone else doing the hard or tedious stuff for them.
Yet despite this, those same people will complain about performance concerns as a reason to avoid FP languages, despite being faster than Python from the start and equally capable of binding to and using C libraries when you need something faster.
The difference here is that with FP languages, since they're smaller, you're more likely to actually have to write the necessary glue code for that C library yourself. Which people don't want to do because, as stated above, they're convinced they need that performance but don't want to deal with the reality of actually getting it. Having to do it yourself is a lot different than when someone else already did the hard part and you can just pretend it was easy.