Mutable array methods

David Bruant bruant.d at
Mon Mar 19 14:36:12 PDT 2012

Le 19/03/2012 21:10, Maël Nison a écrit :
> Hi,
> I'm 'upping' this discussion for two reasons :
> - I didn't send any response before ! I didn't know that some parts of
> V8 were self-hosted, so I'm glad to have learn that. Thanks. : )
> - I've just read this article [1] on the web, and it reminds me this
> discussion. The author is explaining a valid use case of mutable
> functions (preventing useless garbage collection). It's true that in
> real time application, garbage collection consume a lot of processing
> time (factories or persistent objects are not uncommon [2] [3] [4]).
> What do you think about this ?
My opinion hasn't changed. You can still add these methods yourself to
Array.prototype. You are even encouraged to do that and remove methods
abusively creating new arrays if it helps promote array reusability in
your own code.

Regarding garbage collection, I diverged a thread at some point to start
about garbage collection [1]. Allen had really interesting points about
how garbage collection works or could work. Modern web browsers are
getting there.

"Garbage collection consumes a lot of processing time" because people
use it a lot by creating and not reusing. The problem does not come from
the collector, but from those who generate the garbage. Very much like
for actual garbage ;-)

Garbage collection gives the false impression to programmers that they
can stop worrying about memory. But this is a... false impression. You
can have leaks in JavaScript code as well. And if it's easy to not reuse
the memory you've already allocated, you obviously pay it somewhere else.
It's somewhat depressing that someone has to write a blog post to say
"reuse things that are already allocated".



> [1]
> [2]
> [3]
> [4]

More information about the es-discuss mailing list