News for hackers. Stuff that matters.
Re:Why is learning functional programming so damned hard? (2... by macintux on Sunday August 15, 2021 @10:44AM (#28189148)
I would dip my toes into FP occasionally (but very, very briefly) for years. I bought a book on Scheme in 1995, to give you a sense of how long I wandered in the wilderness.

It wasn't until I discovered Erlang in 2012 (thanks, Seven Languages in Seven Weeks) that I finally found the motivation, aided in no small part by the fact that it's a very simple language and it's designed for server programming, where I've always been happiest.

I still haven't graduated into category theory or type theory. I still don't know the difference between a monad and a monoid. But functional programming really speaks to me, because I have an old, tired brain and I need pure functions wherever I can employ them to keep things straight.

Re:Why is learning functional programming so damned hard? (2... by stadium on Sunday August 15, 2021 @01:27PM (#28190541)
Pure functions concept was a breakthrough for me too. As a design pattern they are wonderful, there is so much less mental context to keep track of.

Now whenever I see mutated variables and class attributes, or random side effects besides reading/writing to a database, it kinda makes me cringe and think it's a "oh here we go" into a rabbit hole just to understand what the code is doing. 9/10 the code does what it's supposed to, but the mutations and side effects makes understanding and extending it so much harder.

Re:Why is learning functional programming so damned hard? (2... by m_arnold on Monday August 16, 2021 @01:06PM (#28200353)
If you want to know:

A monoid is just a collection of things that can be associatively "added". Think addition with integers, or append with lists.

Members of the dreaded monad can be sequenced, or composed, while taking into account their context. For instance: if I want to get a value from stdin, then use that value safely; or make a network request and then use the result safely; or run a function that can fail, and use it or short-circuit as needed.

Re:Why is learning functional programming so damned hard? (2... by theCodeStig on Sunday August 15, 2021 @10:23PM (#28194387)
FP can be distilled to purity/referential transparency. Category theory is a nice complement to FP, but it's absolutely not required.
Re:Why is learning functional programming so damned hard? (2... by exdsq on Sunday August 15, 2021 @04:16PM (#28192124)
A monad is just a monoid in the category of endofunctors