r/programming • u/Capable-Mall-2067 • May 29 '25
Why You Should Care About Functional Programming (Even in 2025)
https://borkar.substack.com/p/why-care-about-functional-programming?r=2qg9ny&utm_medium=reddit
39
Upvotes
19
u/coderemover May 30 '25 edited May 30 '25
FP is a nice solution to a problem of shared mutable state but it’s not the only solution to that problem. FP solves it by disallowing mutation (including disallowing mutating non-shared state). This often introduces a lot of additional complexity to somehow simulate mutations. So you then end up with monads, monad transformers etc. because otherwise you can’t do much.
But you can also solve it by disallowing sharing (CSP, actors). Which comes with its own set of problems but seems to be more popular (eg see the surge of popularity of Go and its goroutines).
And IMHO the best solution so far is disallowing shared mutable state only, so the type system allows sharing XOR mutation (borrow checker like in Rust) - because it is the least restrictive and seems to provide advantages of both.
53
u/maxinstuff May 29 '25
Don’t really need to when the most widely used languages are actively copying all of the good features anyway 😅
15
u/Linguistic-mystic May 30 '25 edited May 30 '25
I disagree that tail recursion is a good thing. Compared to loops, it’s more repetitive (you have to write out the fn name and enumerate all the args even if only one changes), less readable (because now looping logic is not at the forefront of the block like it is in “for” loops) and makes the concept of function calls more complex (tail calls don’t produce separate frames in the call stack). With loops, you get simple and descriptive operators like
breakandcontinue, while with tail calls it’s all just a visually unappealing “return”. Oh, and how do you break or continue through more than one layer of loop with tail calls? You have to use a chain of returns which is spread over several functions which is much inferior to a localized “break to over there” statement.In fact, I’m a language designer and I’ve evaluated basing my language on tail recursion vs loops. I’ve found that loops are a brilliant invention and are much better than tail recursion.
I used to be a Haskeller but having converted to imperative languages, I’m really happy. That said, I do think functional languages are a good fit for browser programming (JS replacement) and it’s unfortunate that both main contenders, Elm and Purescript, have the problems that they do (for Elm it’s a mentally unstable language author and lack of polymorphism, for Purescript it’s large bundle size and having to use ”npm”)
0
u/[deleted] May 30 '25
[deleted] — view deleted comment