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
5
u/ragnese Oct 29 '21
I think that can be separate concept from functional programming, though.
In other words, "functional programming" and "representing side effects in the type system" don't have a dependent relationship in either direction.
Functional programming is about pure functions, whether we're talking about a typed or untyped language.
Representing side effects in the type system means that you could have a language that supports impure functions while tracking those side-effects in the type system. This sounds like it's exactly the same thing as Haskell and monads and whatnot, but it's not exactly. Rust is an example. Rust tracks variable mutations as part of the type system, but if you write a bunch of Rust functions that take mutable input parameters, I don't think anybody would look at it and think "Yeah, that's functional programming".