2 ms·
> I am surprised so few interpreters are written in garbage collected languages, which would give the interpreted language a GC for free. 1. not exactly, you'r
by masklinn 8y ago
> I am surprised so few interpreters are written in garbage collected languages, which would give the interpreted language a GC for free.
1. not exactly, you're now doubling your allocations as you're allocating a native object which has to create sub-structues representing the guest object, unless you're using the rpython technique of the interpreter being fed into a magical thing of magic which spits out a "native" runtime
2. the GC of the host language doesn't necessarily match what you want for the guest
3. and not being able to manipulate and interact with the GC can make efficiently implementing the guest difficult
- ori_b 8y ago> 1. not exactly, you're now doubling your allocations as you're allocating a native object which has to create sub-structues representing the guest object Those sub structures can live within the same allocation. And in many cases, the object passed to the interpreter can be the undecorated native object. > 2. the GC of the host language doesn't necessarily match what you want for the guest It's almost certainly better than recounting or naive mark and sweep, which is what you get when someone reimplements a GC for an interpreter.