News for hackers. Stuff that matters.
Re:JavaScript Array.push is 945x faster than Array.concat by antihero on Thursday May 23, 2019 @11:15AM (#19992503)
The idea of "editing" stuff instead of creating new versions of them.

Whilst mutable programming is faster on write, it is much more difficult to figure out if something has changed, so any function that needs to only do work when stuff has changed (e.g. a React component), it is much much better to use immutable style programming because you only have to see if the memory address has changed as opposed to deeply compare current and previous objects.

Re:JavaScript Array.push is 945x faster than Array.concat by yongjik on Thursday May 23, 2019 @01:26PM (#19993814)
If you are doing deep structure compare to check if an object was "changed", you're doing "mutable programming" wrong.

IMHO, if you're doing deep compare on anything for any reason, it's usually a sign that the data model is on a shaky ground.

Re:JavaScript Array.push is 945x faster than Array.concat by skohan on Thursday May 23, 2019 @11:47AM (#19992799)
I disagree that mutable code is inherently faster to write. Like any paradigm you can adopt, it probably feels that way igfyou start injecting immutability into an existing project, but sooner or later you settle into different design patterns which support it better, and it's not faster or slower to write. Probably faster to debug though.
Re:JavaScript Array.push is 945x faster than Array.concat by seanmcdirmid on Thursday May 23, 2019 @11:57AM (#19992880)
Until hardware changes away from being an intrinsically imperative machines, immutable approaches will be slower simply because the hardware doesn’t really support that.

We saw FP hardware leading to performance boosts kind of happen with GPUs (pixel and vertex shaders are just transformers), but then they got back to imperative again with GPGPU.

Re:JavaScript Array.push is 945x faster than Array.concat by wolco on Thursday May 23, 2019 @11:53AM (#19992856)
It is not much better. It is something different. It's popular because of the way React works. It is not always correct because it is easier to understand how state changes. Using array push over concat shouldn't make understanding more difficult and using the slower function for this reason is missing the point.