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". David [1] https://mail.mozilla.org/pipermail/es-discuss/2011-November/018782.html > > [1] > http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript > > [2] https://github.com/arcanis/spark.js/blob/master/lib/factory.js > [3] https://github.com/zz85/sparks.js/blob/master/Sparks.js#L847 > [4] https://github.com/mrdoob/three.js/blob/master/src/core/Matrix4.js#L1038 _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

