News for hackers. Stuff that matters.
Re:Functional programming is not popular because it is weird... by magicalhippo on Tuesday September 14, 2021 @10:36AM (#28525481)
> That's not a "side effect"[1] at all.

Yes, like I said. Point is, in my imperative OOP code, I'm relatively seldom worried about actual side effects, and more worried about introducing bugs due to me not fully grasping all the interactions of the code I'm changing.

Did someone somewhere make an assumption about how this code works (sums all numbers), and am I breaking that assumption when I'm making this change (summing every other number)?

Re:Functional programming is not popular because it is weird... by Tainnor on Tuesday September 14, 2021 @11:01AM (#28525900)
> I'm relatively seldom worried about actual side effects

I'll give you one concrete example: In a number of ORMs, I have no idea when database calls actually happen and this can lead to a) subtle logic bugs (inconsistent state), or b) bad performance (N+1 queries).

I've had such problems both with Ruby's Active Record and Hibernate, two of the most popular ORMs. I've even deployed code that had subtle bugs, even though I wrote tests, because while my tests verified that the correct state of the object was written to the DB, the updated state was not reflected in the JSON response object. I'm sure similar things happen in other frameworks as well.

A PFP can prevent that sort of craziness from happening.

Re:Functional programming is not popular because it is weird... by magicalhippo on Tuesday September 14, 2021 @11:53AM (#28526655)
Fair point, though I'd say such ORMs are broken by design by the sound of things.
Re:Functional programming is not popular because it is weird... by Tainnor on Tuesday September 14, 2021 @11:57AM (#28526706)
I agree that Hibernate in particular is broken by design, but it is what it is...