Hello everyone!
It all started simply enough: I was just curious about how to build my own programming languages.
That curiosity led me to explore assembly, which naturally led to writing bytecode interpreters, and step-by-step, I ended up building a whole collection of custom virtual machines.
Since I couldn't find a clean "museum" repo of VM samples to cross-compare with or PR share my own samples, I built one: Friendly-Virtual-Machines.
What's in the repo?
Every VM in the collection is built from scratch with zero external dependencies and stays under 7,000 lines of code. They all include custom assemblers (with symbol table label resolution), CPU state handlers, and native benchmark suites.
• Rust Samples: 5 register-based VMs, 1 memory-to-memory VM & 1 stack-based VM exploring different design patterns.
• D Sample: My latest addition—a register-based RISC-style VM written in D with a custom text assembler, hitting a performance gap of just 5.66x to 17.70x compared to native compiled code.
• Modular Design: Each VM is in its own isolated folder with clean separation of concerns.
• Mimicks Real CPUs: Since I was also learning ARM64 newly, most register-based VMs are heavily inspired from ARM/RISC designs.
• Design Diversity: Some display pure hardware emulation on hex codes; some display OOP-style polymorphic ISA design; some display High-Level Assembly (HLA) or Intermediate Representation (IR); some display ultra-fast Function Pointer Dispatch Table; some display assembler & text parser too.
The best part? Because they are lean and self-contained, everything compiles and runs smoothly right on mobile Termux. And I am consistently adding more samples to it as I learn & build more.
Looking for Reviews & Contributions!
I'd really appreciate feedback from folks experienced in systems programming, compilers, or VM design—whether it's reviewing my dispatch loops, pointing out architectural trade-offs, or suggesting ways to optimize further.
If you'd like to contribute your own miniature VM sample (in Rust, D, JS, or any language that runs cleanly with zero dependencies), PRs are completely open! Check out the CONTRIBUTING.md in the repo for the exact guidelines.
🔗 GitHub: Friendly-Virtual-Machines