5 ms·
Functional in JavaScript never made sense to me, we don't have immutability in the language. While V8 has made optimisations for short lived objects this doesn'
by ricksnyke 8y ago
Functional in JavaScript never made sense to me, we don't have immutability in the language. While V8 has made optimisations for short lived objects this doesn't hold true across the board so perf can be quite terrible with "pure" style FP.
Theoretically "pure" code is beautiful, in practice it tends to perform badly especially in languages that don't have value types and copy mechanisms.
- scottmf 8y agoDo you have any data to show that this is a real concern with JS?
- tracker1 8y agoIt may depend on the context, and with some VERY large data models, something like even Redux would be less efficient. TBH though, I find that practicing FP in JS even in a less pure form isn't so bad. I tend to prefer shallow clones as responses in favor over mutations. Though I will mutate an object, when it's exclusively inside a function/module and sealed from the outside so that such mutations are at least in isolation.