3 ms·
Why not compile to rust or assembly? C seems like an odd choice. In fact why not simply write rust to begin with?
by GrowingSideways 9mo ago
Why not compile to rust or assembly? C seems like an odd choice.
In fact why not simply write rust to begin with?
- ndr 9mo agoAt times people think C is better. See recent discussion about https://sqlite.org/whyc.html https://sqlite.org/whyc.html
- alexpadula 9mo agoC is best
- xnacly 9mo agoAssembly requires way more work than compiling to, say C. Clang and gcc do a lot of the heavy lifting regarding optimisation, spilling values to the stack, etc
- GrowingSideways 9mo agoThen you're stuck with the C stack, though, and no way to collect garbage.
- saidnooneever 9mo agoreally? you cant track and count your pointers in C? why not?
- UncleEntity 9mo agoI have a couple interpreters I've been poking at and one uses 'musttail' while the other uses a trampoline to get around blowing up the C stack when dispatching the operators. As for the GC, the trampoline VM has a full-blown one (with bells-and-whistles like an arena for short lived intermediate results which get pushed/popped by the compiled instructions) while the other (a peg parser VM) just uses an arena as the 'evaluation' is short lived and the output is the only thing really needing tracking so uses reference counting to be (easily) compatible with the Python C-API. No worries about the C stack at all. I mean, I could have used the C stack as the VM's stack but then you have to worry about blowing up the stack, not having access (without a bunch of hackery, looking at you scheme people) to the values on the stack for GC and whatnot and, I imagine, all the other things you have issues with but it's not needed at all, just make your own (or, you know, tail call) and pretend the C one doesn't exist. And I've started on another VM which does the traditional stack thing but it's constrained (by the spec) to have a maximum stack depth so isn't too much trouble.
- deleted 9mo ago[deleted]
- kuttel2 9mo ago[flagged]
- GrowingSideways 9mo ago> C is the patrician's choice. Is this suppose to be a positive thing? I thought we all wanted to violently murder the patricians. Regardless, C might be a valid IR. I apologize for being bigoted.
- andai 9mo agoTry it again and see how it goes.
- dfox 9mo agoIf I understand the history correctly then it started as a set of C preprocessor macros.