by terminalcommand · 4y ago · 0 comments
Your quote looks like its about bootstrapping the Forth ecosystem. After writing fetch and store operations in native assembly, you can bootstrap the forth system that is logical. This is the way Chuck Moore first used Forth anyways. He had no interpreter/compiler back than, he wrote some functions to aid him circumvent assembly and make his code portable. It is genius, but I think it's still interpreted.
You can compile python to bytecode and run it in python's vm, does this mean your python code is compiled. IMHO no, it is compiled for the python vm and python vm interprets it. Same thing applies to Forth.
Forth is interpreted, even if you compile and package it in a standalone executable binary.
I think it is easier to say forth is closer to compiled. I can kind of imagine each user defined word being translated into assembly. With lisp I am speechles.
As to your speechlessness regarding compiled Lisp, here's a quick example:
CL-USER> (defun foo (n)
(+ 1 n))
FOO
CL-USER> (disassemble #'foo)
; disassembly for FOO
; Size: 35 bytes. Origin: #x53641724 ; FOO
; 24: 498B4510 MOV RAX, [R13+16] ; thread.binding-stack-pointer
; 28: 488945F8 MOV [RBP-8], RAX
; 2C: BF02000000 MOV EDI, 2
; 31: 488BD3 MOV RDX, RBX
; 34: FF14250001A052 CALL QWORD PTR [#x52A00100] ; SB-VM::GENERIC-+
; 3B: 488B5DF0 MOV RBX, [RBP-16]
; 3F: 488BE5 MOV RSP, RBP
; 42: F8 CLC
; 43: 5D POP RBP
; 44: C3 RET
; 45: CC10 INT3 16 ; Invalid argument count trap
NIL
CL-USER>
(SBCL was used for the above)"The logic inside that helps dispatch based on the dynamic types at runtime" is the interpreter part IMHO. Plus you need logic to add the metaprogramming elements that require you to change the code after it has been written.
We need to generate an example of something we can't do in C, something which requires evaluation at runtime.