Tumble Forth – from assembly to OS with C compiler (2023)(tumbleforth.hardcoded.net) |
Tumble Forth – from assembly to OS with C compiler (2023)(tumbleforth.hardcoded.net) |
Reminds me of preppers hoping for an apocalypse that makes their buckets of dried food valuable but leaves their access to fresh water and medicine intact.
It's probably an interesting series regardless, I just find that framing silly
> We'll go bare metal and then build an operating system of our own, with a C compiler of our own. It's simpler this way.
I love the audacity of those statements. And I appreciate this sort of approach which says "let's implement the simplest possible version of _______ to learn how it is done."
Tumble Forth - https://news.ycombinator.com/item?id=38184539 - Nov 2023 (22 comments)
>"The Forth interpret loop is very simple:
1. Read a word [string] from input.
2. Is it a number?
3. Yes? [Convert it and] Push that number to [the] Parameter Stack and go to 1.
4. No? Then is that word [string] in the dictionary?
5. Yes? Execute it [look up the associated address in memory and jump to it] and go to 1.
6. No? “Word not found” error. Go to 1."
...basically, that's all a Forth Interpreter is(!), in pseudocode (or in higher-level English as a code abstraction, if you prefer...)
(Key observation: There are no additional parameters to parse, no additional parameter lists to pass, because every FORTH function works on whatever data is in the stack, directly. (Every FORTH function could be said to be 'generic' from that perspective.) Which means that all we really need to do is look up the address for a function name and jump to it. That, and have a way to put parameters onto the stack. And that's all we basically need!)
Language compilers and language interpreters (programs that implement an underlying programming language) -- do not get much simpler!
Compare (cf.) the above to the complexity of the simplest compiler, or even the complexity of the simplest LISP (or LISP-like language) interpreter... it's simpler and less complex than either of those...