News for hackers. Stuff that matters.
Re:Crank.js – Write JSX-driven components with functions, pr... by crubier on Saturday April 18, 2020 @03:05AM (#22905887)
The annoying thing with function purity fanaticism is that it is out of touch with reality.

State. Exists.

State exists, so let’s deal with it with the tools that the language provides, instead of pretending it does not exist, just to realize later that it does and jamming as hoc answers to this initial oversight.

A UI component is fundamentally “something that generates values (view objects) asynchronously (over human-scale timeframes)”. That’s the definition of an async generator!

Re:Crank.js – Write JSX-driven components with functions, pr... by josteink on Saturday April 18, 2020 @03:23AM (#22905955)
> The annoying thing with function purity fanaticism is that it is out of touch with reality. State. Exists.

It’s the opposite of all-state fanaticism, where nothing can be done or calculated without first 1. Creating classes, 2. Mutating their states, and often 3. Mutating global state.

And then... magic!

Both kinds of fanaticism are bad, and a middle-ground is probably best. Keep it simple. Use the best tool for the job, etc.

That said, having worked with lots of code deeply inflected with global state, I’m more lenient to accept function-purity fanaticism over all-state fanaticism because at least then you only need to understand this one local oddity, not how it depends on the entirety of the rest of the codebase.

Re:Crank.js – Write JSX-driven components with functions, pr... by crubier on Saturday April 18, 2020 @03:29AM (#22905975)
I agree with that and I personally dislike OOP a lot and am much more on the FP side. But sometimes as you say a middle ground is best, especially when the thing is intrinsically stateful.

But I have to say Dan Abramov does a good job of explaining why they need that purity here and it makes sense https://www.reddit.com/r/javascript/comments/g1zj87/crankjs_...

Re:Crank.js – Write JSX-driven components with functions, pr... by exdsq on Saturday April 18, 2020 @04:54AM (#22906297)
I think the state monad in F# makes a lot of sense - I'm now on the functional side after (finally) understanding it.
Re:Crank.js – Write JSX-driven components with functions, pr... by rienbdj on Saturday April 18, 2020 @03:23AM (#22905959)
Parent was arguing against putting state in functions when classes exist. They weren’t arguing against state full code.