2 ms·
Forth isn't slow because it can be compiled to machine code, which is not even touched on by the article. The main argument of the article seems to be reiterat
by kazinator 6y ago
Forth isn't slow because it can be compiled to machine code, which is not even touched on by the article.
The main argument of the article seems to be reiterating the idea that in a tree, most of the nodes are leaves. For instance, in a balanced binary tree containing 2^n-1 nodes, a little over half the nodes are leaves. So if we visualize the call graph as traversing a tree, where the leaves are primary primitives in machine language, the bulk of the activity is always going on in the machine language leaves. When a primitive operation returns, much of the time control soon passes to another primitive operation, staying near the bottom of the tree.
- nybble41 6y ago> When a primitive operation returns, much of the time control soon passes to another primitive operation, staying near the bottom of the tree. Depending on how the threading is implemented, the primitive "return" (NEXT) operation may even pass control directly to the next primitive; a typical threaded implementation of NEXT might be something along the lines of "load next codeword and branch to it". You only go through the full call/return sequence, e.g. updating the return stack, when entering or leaving a non-primitive word.