2 ms·
A big issue it seems that these immutable libraries and Redux seem to neglect is JavaScript's OO nature. I'm talking about instantiated function declarations, s
by jameslk 11y ago
A big issue it seems that these immutable libraries and Redux seem to neglect is JavaScript's OO nature. I'm talking about instantiated function declarations, something that's more readily available with ES6's class notation. Most of these libraries (sans Redux) take advantage of this aspect of JavaScript, yet leave you to figure things out if you do the same. This blog post kind of touches upon this regarding Map and Set.
Now, functional programming is nice and lends itself some useful benefits, but unfortunately JavaScript just wasn't built in the value-oriented sense. And given the native features of JavaScript, such as the ability to create "classes," I'd like to take advantage of these features and reap all their benefits, such as encapsulation (which of course, some in the FP community don't seem to care about[1]).
I'd like to see a middle ground somewhere between having e.g. immutable objects yet respecting the way JavaScript is built. Until then, I'd have to ditch common JavaScript idioms, which are only being advanced in ES6. Not something I'm very keen on doing.
1. http://programmers.stackexchange.com/a/216358 http://programmers.stackexchange.com/a/216358
- k__ 11y agoFlux seems linke the FP equivalent to the OOP mvc to me. So there is no need for what you say.
- jameslk 11y agoI don't follow the point you're trying to make. What I'm referring to is how JavaScript's object orientedness, which relies heavily on references, doesn't play very well with immutable values. The only way to really eschew mutability is to ditch the concept of objects representing a state and a set of methods that mutate its state (which maintain encapsulation and enforce separation of concerns). Unless you decide to make all your prototype methods return new instances of the constructor upon mutation, which would be both inefficient and prone to error.