
Ask HN: What's a good tutorial for writing a stack-based virtual machine? - sdegutis
Eventually I&#x27;d like to write my own language like Lua (but stack-based), mostly for fun and partly for practice. But I don&#x27;t fully understand a lot of aspects of how a virtual machine like that works. Can you recommend a good tutorial on it? Thanks!
======
jacquesm
Do a small Forth implementation. Shouldn't take you more than a few days and
you'll learn a ton about stack machines VM or otherwise.

Brodie's 'Staring Forth' would be a good point to branch out from. It's fun
and it will maybe give you a new perspective on programming.

------
sgrossman
I remember this lecture being useful when I was writing a stack machine for my
compilers course:
[https://class.coursera.org/compilers/lecture/62](https://class.coursera.org/compilers/lecture/62)

------
pinewurst
There used to be one as part of the ANTLR Advanced Tutorial. I used that to
bootstrap a fairly complex expert systems shell used as the core of a few
things.

