3 ms·
Why not implement the GCs themselves using low-level WASM code? That would enable a language-agnostic approach (though it would prohibit collecting garbage over
by amelius 8y ago
Why not implement the GCs themselves using low-level WASM code? That would enable a language-agnostic approach (though it would prohibit collecting garbage over multiple cooperating languages at the same time, which is a less urgent problem imho).
- rkangel 8y agoYou've already got 2 co-operating languages - JS and whatever is compiler to WASM.
- amelius 8y agoTrue, but once you're using WASM, you probably don't need to hold references to JS objects that point back to the objects created in WASM. We've been interfacing C with e.g. Python without needing a garbage collector that crosses language boundaries. So why would we need one now?
- TomMarius 8y agoBecause that's not safe. It's only as safe as the Python binding is, which is not good enough.
- amelius 8y agoDefine "safe". Are you talking about security or correctness, or both, and please elaborate.
- TomMarius 8y agoThe point of WASM is the ability to safely run any untrusted code in a performant way, that includes seamless interfacing with other modules. https://webassembly.org/docs/security/ https://webassembly.org/docs/security/
- amelius 8y agoI'm sure that if you can make WASM secure without the GC part, then you can create a safe interface. Yes, it may leak memory (remember, so can a GCed program that forgets to unreference objects), but that's just something you have to deal with when programming at a low level; and languages built on top of WASM can make that a non-issue, actually. Let's keep WASM simple. It's probably the best thing one could do in view of security.
- TomMarius 8y agoCan you elaborate on how two WASM modules each with its own GC could safely interface without unnecessary overhead? Why would we want to have this overhead in the first place? It may not be that bad with 2 modules, but you might easily have 20 or (way) more.
- de_watcher 8y agoI've got multiple specialized GCs within one module, and they're doing fine. Trying to shoehorn everything into one model isn't something that should have 'asm' in its name.
- TomMarius 8y agoOK, but could you share the specifics? I'd like to understand. Emphasis on combination of safety (primary) and performance (secondary) - remember that any number of completely unrelated, untrusted, maybe buggy and potentially even malicious modules might be combined. They're being very careful about not forcing languages into one model, BTW.
- rkangel 8y ago> We've been interfacing C with e.g. Python without needing a garbage collector that crosses language boundaries. So why would we need one now? Because C doesn't need garbage collection, it uses 'manual' memory management. This scenario is exactly analogous to the WASM-JS world that exists now (WASM is manual, and JS is GC). The goal here is to have a GC that's usable in WASM, and WASM is going to be interoperating a lot with JS for many applications, so it needs to cope with that. A better analogy in this case would be IronPython which is Python built on the .NET framework rather than C. In that case, the Python GC is the .NET GC, so that objects can be passed back and forth 'between worlds'.
- TomMarius 8y ago> (though it would prohibit collecting garbage over multiple cooperating languages at the same time, which is a less urgent problem imho). That's the whole reason they're adding a GC, how is it not an urgent problem?
- fulafel 8y agoYes, the target audience for WebAssembly seems to be performance-conscious application authors who use non-GC'd languages, and unpredictable GC is a headline reason for choosing WS in those circles. So giving authors control over GC would be a fine thing to deliver, it would let real-time app authors still use GC in a controlled fashion. It could probably be done in a way that allowed multiple GC's to coexist and cooperate.
- hajile 8y agoThe kinds of memory guarantees and controls a GC wants for good performance seem to be the kind of things you wouldn't want to give to some random third-party.