|
|
|
|
|
by scatbot
216 days ago
|
|
Any Forth system at it's core is essentially a stack-based virtual machine with a reprogrammable high-level assembler and a REPL. Some Forths use direct or indirect threading, others are implemented as bytecode VMs, not unlike the JVM, high-performance JavaScript engines or the Erlang VM, but that's really just an implementation detail. People say that stack juggling is boring, but I actually find it to be a very natural way to think about computation. Forth's linear, concatenative style gives you SSA-like semantics for free, which makes it straightforward to lower into register-optimized bytecode or native code. And once you're there, dynamic recompilation at runtime can do the rest. A naive, threaded implementation of Forth might not be performance-friendly on modern hardware, but there's nothing that prevents it from being high-performance. It just depends on how much effort you're willing to put into the implementation. |
|