# Your First Virtual Machine: Write yourself a compiler, Part IV

DevFeed: [Your First Virtual Machine: Write yourself a compiler, Part IV](<https://devfeed.tech/articles/your-first-virtual-machine-write-yourself-a-compiler-part-iv-38040.md>)

Original publisher: [Read original article](<https://nurkiewicz.com/2026/08/your-first-virtual-machine-write-yourself-a-compiler.html>)

Published: 2026-08-24T22:00:00Z

Content type: tutorial

Language: en

Sources: [Tomasz Nurkiewicz around Java and concurrency](<https://devfeed.tech/sources/tomasz-nurkiewicz-around-java-and-concurrency.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [clojure](<https://devfeed.tech/tags/clojure.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [feature](<https://devfeed.tech/tags/feature.md>), [go](<https://devfeed.tech/tags/go.md>), [interpreter](<https://devfeed.tech/tags/interpreter.md>), [reverse-polish-notation](<https://devfeed.tech/tags/reverse-polish-notation.md>), [stack](<https://devfeed.tech/tags/stack.md>), [virtual-machine](<https://devfeed.tech/tags/virtual-machine.md>), [vm](<https://devfeed.tech/tags/vm.md>), [writing-compiler](<https://devfeed.tech/tags/writing-compiler.md>)

## AI overview

This tutorial explains how to build a virtual machine that reads and executes a binary intermediate representation. It covers the instruction loop, operand stack, arithmetic operations, postfix notation, and how the resulting executable compares with JVM files and .NET assemblies.

## Source excerpt

In the previous article, we emitted an intermediate representation (IR) for our programming language that is easier to process than source code. However, we did not build a program that could read and execute that IR. Such a program is called a virtual machine. Technically, it's still an interpreter. But instead of interpreting source code, it interprets IR. Our IR is binary, compact, structured, and generally faster to interpret than the original source. Moreover, as you'll see later, the VM's instruction set can express programs that our source language cannot produce yet!