Remix.run Logo
MaxBarraclough 3 days ago

> Very fast (faster than naive assembler)

Every Forth that uses conventional threaded-code interpretation pays a considerable performance penalty, execution times are likely to be very roughly quadruple the equivalent assembly. [0]

Forth's runtime performance can be competitive with C if 'proper' compilation is performed, though. [1]

[0] https://benhoyt.com/writings/count-words/

[1] (.fth file with their results in comments) http://www.mpeforth.com/arena/benchmrk.fth

PittleyDunkin 3 days ago | parent [-]

This is true. It's not terribly difficult to bootstrap an (inlining) compiler from a threaded interpreter, though, including eliding a lot of stack operations.

I'm curious if anyone has tried using futamura projections to do this in stages. I hadn't known about them when I last built a forth and it may yield more satisfying, incremental results than the last time.