Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You and I had this exact conversation at Eataly a few months back. WeakMaps are cool, but JS is a garbage-collected language. All you have to do to GC something is stop referencing it.

WeakMaps are only really useful when you don't control the referenced object's lifecycle. Even then, you can simply invert your map or check in your callback.



> JS is a garbage-collected language. All you have to do to GC something is stop referencing it.

That works well for JS... but if you are trying to use asm.js (or now wasm), you need to act on things getting garbage collected inside of your code.


You're talking about implementing your own GC inside JS. A valid use case, but a niche one. JS the language doesn't really need to expose GC internals. JS the compile target does. (Though it can be worked around).


> You're talking about implementing your own GC inside JS. A valid use case, but a niche one.

Any asm.js code that calls into DOM apis is going to need this. Otherwise they don't know when to free stuff.

Most of the current asm.js code out there just binds a single canvas element, and works with that. But if you want to actually call anything else....




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: