Live data from Hacker News

Learn Functional Programming Design from Redux

pitayan.com

11–20 of 48 posts

Re: Learn Functional Programming Design from Redux

#11

In my experience learning, teaching, and watching other people learn FP, it's far easier to learn FP with a language which is actually designed for it, e.g. , Elm. JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. There's a reason why someone had to write The Good Parts . I don't buy the idea either that modern JavaScript is somehow devoid o…

I think it depends. It's hard to learn more than one thing at once; if you already know JS well, learning about functional programming using it makes sense to me. It's tricky to learn both a new language paradigm and a new syntax at the same time. Of course there are limitations to how functional you can really be in JS; that said, I like the idea of introducing some basic concepts with JS. If people like the idea, t…

Yeah, this is what happened to me. FP was really easy purchase for me with JS because of its numerous flaws. But in the end, it got tiresome to have to write libs and import them around to keep the ick away, and because the lang ecosystem was doubling down on enterprise OOP conventions with TS, I decided to move away to Haskell.

Re: Learn Functional Programming Design from Redux

#12

In my experience learning, teaching, and watching other people learn FP, it's far easier to learn FP with a language which is actually designed for it, e.g. , Elm. JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. There's a reason why someone had to write The Good Parts . I don't buy the idea either that modern JavaScript is somehow devoid o…

This is my experience as well. I had a co-worker that really pushed for FP in JavScript using Ramda.js. the principles were appealing, but because JavaScript doesn't have native syntax for many of the principles like pattern matching, you end up with hard to read code that's a bunch of nested arrays or chains wrapped in helper functions like "compose([fn1, fn2])(data)".

I later tried to learn F# and while the syntax was foreign, it turned out that it was MUCH easier to write FP code because the language had native operators for composition, etc. The code was also much easier to read.

I think it would be great if JavaScript got some FP syntax natively (see the pattern matching proposal). But hacking functional principals using arrays and helper functions just leads to hard to read code, especially for people not familiar with the specific FP library you chose to use.

Re: Learn Functional Programming Design from Redux

#13
post #10

Earlier quoted context omitted.

Learning new syntax really isn't hard. Bear in mind that quite a lot of supposedly "modern" JavaScript is new syntax.

Learning new syntax really isn't hard. When you make an absolute claim like "Learning new syntax really isn't hard." you're really saying "I find it easy therefore everyone else must too." That's poor quality thinking at best, and actively toxic to your peers at worst. In my twenty+ years as a mentor to developers I've learned that objective statements about what is and isn't hard in programming are always going to f…

I think at some point we need to stop infantilising our peers. It isn't toxic when one child says to another that speaking in Pig Latin isn't hard. The difference between `function add(a, b) { return a + b; }` and `add a b = a + b` is about as superficial as the difference between Hello World and Ellohay Orldway. In fact, as I've already alluded to, syntax swaps don't even need to span different programming languages — "modern" JavaScript uses different function expression syntax.

Describing syntax swaps as a "move from one mental model to another" is intellectually dishonest.

Re: Learn Functional Programming Design from Redux

#14

In my experience learning, teaching, and watching other people learn FP, it's far easier to learn FP with a language which is actually designed for it, e.g. , Elm. JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. There's a reason why someone had to write The Good Parts . I don't buy the idea either that modern JavaScript is somehow devoid o…

> JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy.

Not only that. If you use types, and then an FP library, and then immutability, these three are at always at odds with each other.

Re: Learn Functional Programming Design from Redux

#16

In my experience learning, teaching, and watching other people learn FP, it's far easier to learn FP with a language which is actually designed for it, e.g. , Elm. JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. There's a reason why someone had to write The Good Parts . I don't buy the idea either that modern JavaScript is somehow devoid o…

> JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. Not only that. If you use types, and then an FP library, and then immutability, these three are at always at odds with each other.

Very correct.

In addition, it becomes a real pain when using generics with constraints in TS. TS doesn't support either type classes or module/namespace level generics so you end up duplicating the same constraints applied to generic parameters across several functions.

It is often easier to just use stateless classes instead and incur the runtime overhead of instantiation even if that object serves no purpose.

Re: Learn Functional Programming Design from Redux

#17
post #15

main :: (RealWorld ->) ((), RealWorld) I've been doing haskell for a few months now. I don't think I have ever seen a expression like this. It looks like State. Is this even valid syntactically? I'm Probably bikeshedding.

The Haskell snippet included is basically gibberish. It’s best to ignore it.

Re: Learn Functional Programming Design from Redux

#18
post #7

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. It's like telling someone who wants to learn to drive, here's the road laws book, car manual, car service manual, offroad rally driving guide and engine t…

Redux was my first introduction to FP, and I loved it. You simply have to use Redux Toolkit that takes care of the ugly parts of Redux (namely: the boilerplate code), and it becomes a breeze to build things with Redux.

Re: Learn Functional Programming Design from Redux

#19

In my experience learning, teaching, and watching other people learn FP, it's far easier to learn FP with a language which is actually designed for it, e.g. , Elm. JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy. There's a reason why someone had to write The Good Parts . I don't buy the idea either that modern JavaScript is somehow devoid o…

Are you implying that const _doesn’t_ give you an immutable value? Or are you purposefully ignoring the difference between a primitive value and a pointer to make your point?

Re: Learn Functional Programming Design from Redux

#20
post #15

main :: (RealWorld ->) ((), RealWorld) I've been doing haskell for a few months now. I don't think I have ever seen a expression like this. It looks like State. Is this even valid syntactically? I'm Probably bikeshedding.

The Haskell snippet included is basically gibberish. It’s best to ignore it.

Has it been removed? I don't see any Haskell in the article.
Post reply on HN