Remix.run Logo
int_19h 7 days ago

> * Rest/spread operators hide that you're allocating new arrays and objects.

Only in function calls, surely? If you're using spread inside [] or {} then you already know that it allocates.

hajile 7 days ago | parent [-]

It used to be said that "Lisp programmers know the value of everything and the cost of nothing."

This applies to MOST devs today in my experience and doubly to JS and Python devs as a whole largely due to a lack of education. I'm fine with devs who never went to college, but it becomes an issue when they never bothered to study on their own either.

I've worked with a lot of JS devs who have absolutely no understand of how the system works. Allocation and garbage collection are pure magic. They also have no understanding of pointers or the difference between the stack and heap. All they know is that it's the magic that makes their code run. For these kinds of devs, spread just makes the object they want and they don't understand that it has a performance impact.

Even among knowledgeable devs, you often get the argument that "it's fast enough" and maybe something about optimizing down the road if we need it. The result is a kind of "slow by a thousand small allocations" where your whole application drags more than it should and there's no obvious hot spot because the whole thing is one giant, unoptimized ball of code.

At the end of the day, ease of use, developer ignorance, and deadline pressure means performance is almost always the dead-last priority.