this post was submitted on 09 Oct 2025
3 points (80.0% liked)

Functional Programming

1591 readers
1 users here now

founded 2 years ago
MODERATORS
top 4 comments
sorted by: hot top controversial new old
[–] orclev@lemmy.world 2 points 1 month ago* (last edited 1 month ago) (1 children)

I think he's far too quick to dismiss the idea of no side effects. Or rather I think he's taking an absolutist stance. The problem isn't so much the side effect as it is the ability to introduce side effects arbitrarily with no warning to someone using your functions. To be fair I think the only relatively mainstream language that actually does something about this problem is Haskell with the IO monad (and to a much lesser extent Rust via unsafe). Just as Rust tackled the problems of concurrency through the language concept of ownership I think there's room to tackle side effects at the language level as well. Haskell does it one way, but there're potentially other approaches that could achieve the same goals in a hopefully slightly more approachable manner (insert monads are a endofunctor in the category of copypasta here).

Related to the idea of no side effects I think it's also really important to call out the concept of total functions, something it's incredibly hard to reason about in most languages but that's trivial in Haskell and not totally horrendous in Rust.

[–] mrh@mander.xyz 2 points 1 month ago* (last edited 1 month ago)

The problem isn’t so much the side effect as it is the ability to introduce side effects arbitrarily with no warning to someone using your functions

Yes, I try and briefly allude to this in the "caution" and "tldr2" sections, but I think I could have been more clear. You are right that for many people it's not so much about avoiding side effects as it is about coming up with ways to use them carefully. Stateful monads and clojure's atoms/refs were in fact what I had in mind. And debating the pros/cons of these techniques is indeed a good conversation on its own! What I mostly wanted to get across is that fp is not about programming without side effects. All the good debate is about the extent to which we should try to avoid side effects, and what techniques we should use when doing so.

I think it’s also really important to call out the concept of total functions

Yeah I think this is totally (heh) worth talking about, and a much better topic than pure functions. I only didn't mention it because I don't see it brought up too often.

[–] gozz@lemmy.world 2 points 1 month ago (1 children)

This reads like a parody to me. They almost seem to be trying to find a way to warp and misunderstand even the most basic concepts to contort themselves to miss the point. I honestly am baffled as to how such a seemingly-contrived misinterpretation of absolutely everything at every step of the way could happen by accident. But I suppose the internet is a billion monkeys at a billion typewriters so maybe it had to happen eventually.