2 ms·
"My history with Forth & stack machines" at https://yosefk.com/blog/my-history-with-forth-stack-machines.html https://yosefk.com/blog/my-history-with-forth-stac
by eesmith 4y ago
"My history with Forth & stack machines" at https://yosefk.com/blog/my-history-with-forth-stack-machines.html https://yosefk.com/blog/my-history-with-forth-stack-machines... hits HN every year or more - https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=My%20history%20with%20Forth%20%26%20stack%20machines&sort=byDate&type=story https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu... .
The most relevant parts are:
> We thought about making our own CPU. The person with the overall responsibility for the hardware design gently told me that I was out of my mind. CPUs have register files and pipeline and pipeline stalls and dependency detection to avoid those stalls and it's too complicated.
> And then I asked, how about a stack machine? No register file. Just a 3-stage pipeline – fetch, decode, execute. No problem with register dependencies, always pop inputs from the top of the stack, push the result.
> He said it sounded easy enough alright, we could do that. "It's just like my RPN calculator. How would you program it?" "In Forth!" ...
> It was among the most painful programming experiences in my life. ...
> Speaking of which. I started to miss a C compiler. I downloaded LLVM. (7000 files plus a huge precompiled gcc binary. 1 hour to build from scratch. So?) I wrote a working back-end for the stack machine within a week. Generating horrible code. Someone else wrote an optimizing back-end in about two months.
> After a while, the optimizing back-end's code wasn't any worse than my hand-coded Forth.