4 ms·
A naive (ie. threaded[1]) Forth implementation will be slow because the jump between each instruction is a very effective way to defeat branch prediction. Of c
by rwmj 8y ago
A naive (ie. threaded[1]) Forth implementation will be slow because the jump between each instruction is a very effective way to defeat branch prediction. Of course this doesn't apply to "real Forth" which is compiled into machine code or even less naive Forths which can do inlining, but there are many hobbyist Forth implementations (because they're so easy to write) where this will still be true.
If you're interested I wrote a naive literate Forth implementation which can do inlining: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth.S http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth.f http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth...
[1] "Threaded" in this sense means https://en.wikipedia.org/wiki/Threaded_code https://en.wikipedia.org/wiki/Threaded_code not multithreading.
- gmfawcett 8y agoI've always meant to thank you for publishing jonesforth. I learned so much from it. (I can't believe it's been nearly ten years now!) It's a beautiful example of literate programming. Knuth would be proud, I think!