3 ms·
Ouch those limitations though. Given the performance problems some of them sort of make sense I guess, but: * adding "get by index" and "put by index" commands
by o11c 3y ago
Ouch those limitations though. Given the performance problems some of them sort of make sense I guess, but:
* adding "get by index" and "put by index" commands would significantly improve flexibility compared to only being able to access 3 elements of the stack (admittedly less useful given the limit of 8 total)
* if you perform a sort of pre-compilation pass to generate a sort of bytecode (even to just an array of functions, though I would also add an argument field since stack form sucks), and optimize constants like numbers, execution will be much faster.
- chmod775 3y ago> if you perform a sort of pre-compilation pass to generate a sort of bytecode Generate JS and throw it through eval/new Function. The JS engine is going to beat by a mile whatever you can come up with within the constraints of JS.
- Lerc 3y agoThat's more or less what I did with C50. I wrote a simple translator to turn the stack based code into JavaScript expressions, then created a function via new Function. It came out a couple of orders of magnitude faster than the interpreted version.