3 ms·
Debugging is not a problem per se. As an example you can see how Nim generates debugging info while transpiling to C with the --debuginfo --linedir:on options.
by register 7y ago
Debugging is not a problem per se. As an example you can see how Nim generates debugging info while transpiling to C with the --debuginfo --linedir:on options. The real problem with C transpilation is proper garbage collection support. A C compiler doesn't track roots and that means that for a language transpiled to C it is not practically feasible as of today to support garbage collection algorithms that are not conservative. There are published tecniques that should allow implementing full non conservative GC on top of C but they have remained in research settings so far.As a matter of fact the de facto standard GC for such langauages is Bohem's which has known limitations.
- tom_mellior 7y agoA C compiler doesn't track roots, but it does not follow that precise GC is impossible in code that compiles to C. You "just" need to make sure that your translator emits the appropriate code. Nobody forces you to implement assignments in the guest language as literal C assignments. If a guest language assignment statement compiles to something like "assign(&target, value)", then your assign function can do whatever it takes to track roots.
- register 7y agoAgreed that it can be done but at a considerable cost. Translating every assignment into a function call is within what I didn't consider feasible from a practical point of view. The best research papers I saw on this topic proposed to pass an additional "ghost stack" as a parameters in every function call that is structured in a specific way so that roots are not "optimized away" by the compiler.