TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learn Functional Programming Design from Redux

58 pointsby daiyanzealmost 5 years ago

5 comments

yakshaving_jgtalmost 5 years ago
In my experience learning, teaching, and watching other people learn FP, it&#x27;s <i>far</i> easier to learn FP with a language which is actually designed for it, <i>e.g.</i>, Elm.<p>JavaScript isn&#x27;t that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It&#x27;s also just super noisy.<p>There&#x27;s a reason why someone had to write <i>The Good Parts</i>. I don&#x27;t buy the idea either that <i>modern</i> JavaScript is somehow devoid of the kinds of problems that existed when Crockford wrote that book. I mean, how many people <i>still</i> think that `const` gives you an immutable value?<p><i>n.b.</i> I&#x27;m not sure why the Haskell snippet was included. It&#x27;s confusing, and doesn&#x27;t even make sense given that `main` is defined twice.
评论 #24047813 未加载
评论 #24047634 未加载
评论 #24047697 未加载
评论 #24047550 未加载
评论 #24047927 未加载
评论 #24048815 未加载
评论 #24049078 未加载
评论 #24050067 未加载
hasperdialmost 5 years ago
IMO Redux is a terrible way to start learning functional programming. There is too much boilerplate code and other code (ie. reducer, selectors, side effects, react components) that will confuse beginners and make the goal of learning functional programming harder.<p>It&#x27;s like telling someone who wants to learn to drive, here&#x27;s the road laws book, car manual, car service manual, offroad rally driving guide and engine tuning manual.
评论 #24048664 未加载
评论 #24048901 未加载
diegof79almost 5 years ago
While I use Redux, and I like the simplicity of the single application state and the reducer function. I don&#x27;t see it as a good example of FP or even JavaScript.<p>The problem with Redux is that it takes many patterns that make sense in languages like Haskell or Elm but are not idiomatic in JS. For example, action types and the usual reducer switch statement is easier to write and extend in Haskell.<p>And is not idiomatic JavaScript either. It always baffles me that an action dispatch is a way of doing a method dispatch (and yes I know that unlike a method dispatch an action can be persisted, and broadcasted). But if you compare the boilerplate and concepts introduced by a simple action dispatch (action creator, action type, payload, thunk, middleware) with a simple method call, and you look at the benefits (late binding with the state, persistence)... I wonder why solutions like Zustand didn&#x27;t come up before.<p>(note, I wrote state management code similar to Zustand for my personal projects, but one of the reasons to continue using Redux is that getting the Context updates right is hard... a problem solved by React-Redux with addition of nice tooling and collaboration from core React devs. As soon React adds fine-grained context state updates the reasons to continue using Redux for me are low).
acemarkealmost 5 years ago
Side note: I just published a brand-new &quot;Redux Essentials&quot; core docs tutorial. It teaches beginners &quot;how to use Redux, the right way&quot;, using our latest recommended tools and practices, including Redux Toolkit for writing your Redux code, the React-Redux hooks API for interacting with Redux in your components, and use of single-file &quot;slices&quot; for a given feature&#x27;s Redux logic. I&#x27;d encourage folks to check it out:<p><a href="https:&#x2F;&#x2F;redux.js.org&#x2F;tutorials&#x2F;essentials&#x2F;part-1-overview-concepts" rel="nofollow">https:&#x2F;&#x2F;redux.js.org&#x2F;tutorials&#x2F;essentials&#x2F;part-1-overview-co...</a><p>My next step will be to rewrite the existing &quot;bottom-up&quot; tutorial sequence to simplify explanations, remove outdated references, improve the explanation flow, and add more running examples.
评论 #24047649 未加载
wqsz7xnalmost 5 years ago
<p><pre><code> main :: (RealWorld -&gt;) ((), RealWorld) </code></pre> I&#x27;ve been doing haskell for a few months now. I don&#x27;t think I have ever seen a expression like this. It looks like State. Is this even valid syntactically? I&#x27;m Probably bikeshedding.
评论 #24048661 未加载