News for hackers. Stuff that matters.
Re:Why Functional Programming Should Be the Future of Software by tsimionescu on Wednesday November 02, 2022 @02:44PM (#33440931)
> The other part is FP's a bit of a mind fuck if you're used to procedural programming

It's not "if you're used to procedural programming" - FP is simply hard for people to reason about. You can often very intuitively reason about imperative programs, while FP always requires putting your abstract thinker cap on. Look at any non-software person describing describing how to do something and see how often that sounds like an imperative program vs an FP one. Hell, most algorithms papers are themselves using imperative pseudo-code, not FP pseudo-code (unless they're specifically describing novel algorithms important for FP of course).

> I am convinced the more we try to make mutable state, and concurrency safe and correct, the more FP concepts will leech into future languages.

Concurrent mutation is fundamentally hard regardless of what paradigm you chose to implement it in. Parallelism can be made safer by FP, but parallelism is actually pretty easy in every paradigm, with even a little bit of care. And concurrent updates of mutable state are just a fundamental requirement of many computer programs - you can try to wrap them in monads to make them more explicit, but you can't eliminate them from the business requirements. The real world is fundamentally stateful*, and much of our software has to interact with that statefullness.

* well, at least it appear so classically - apparently QM is essentially stateless outside its interactions with classical objects (the Born rule), but that's a different discussion.

Re:Why Functional Programming Should Be the Future of Software by BlargMcLarg on Wednesday November 02, 2022 @02:57PM (#33441170)
Eh, it really depends. Some people find trees easier to navigate through recursion than iteration, same for lists and graphs. Some do better using decomposition on a list to get a combined value or create permutations than doing it through iteration and indexing. FP commonly becomes problematic when things are far more trivial to do stateful than stateless, with side-effects than without, and more.

FP usually shines in small sections of easily isolated code, where it is still trivial to grasp for most and its strengths show more than its weaknesses. Given that code isn't more easily expressed using iteration, anyway. The moment things have to be woven together and not leave any side-effects is when the difficulty jumps to 11.

Re:Why Functional Programming Should Be the Future of Software by tsimionescu on Wednesday November 02, 2022 @04:01PM (#33442123)
Sure, there are contexts where the functional approach is actually more natural - especially already highly abstract contexts. I actually like to use certain functional paradigms in my day to day programming (or did, before switching to Go). I just dislike the claim that imperative code is simply more familiar and not more natural/intuitive (in general).
Re:Why Functional Programming Should Be the Future of Software by tankorsmash on Thursday November 03, 2022 @10:12AM (#33451287)
> It's not "if you're used to procedural programming" - FP is simply hard for people to reason about.

It's relatively straightforward once you understand the patterns and idioms, just like procedural programming. `age |> add10 |> substract9` is about as readable as `add10(substract9(age)`, but we're just so used to the latter.