Z-Machine
The portable text adventure engine
Infocom's virtual machine that allowed text adventures to run identically on dozens of platforms, anticipating portable runtime concepts by decades.
Overview
The Z-Machine was a virtual machine designed by Infocom for text adventure games, allowing a single game file to run on any platform with a Z-Machine interpreter. Created primarily by Marc Blank and Joel Berez, it let Infocom release games simultaneously on Apple II, Commodore 64, IBM PC, Atari, and dozens of other systems - all playing identically.
The concept anticipated Java and other portable runtimes by nearly two decades.
Fast Facts
- Created: 1979
- Designers: Marc Blank, Joel Berez
- Company: Infocom
- Versions: Z1 through Z8 (Z3 most common)
- File extension: .z3, .z5, .z8, etc.
- Modern use: Inform compiler targets Z-Machine
How It Worked
| Component | Function |
|---|---|
| Story file | Compiled game data (platform-independent) |
| Interpreter | Platform-specific Z-Machine implementation |
| Bytecode | Instructions for text, logic, world state |
| Memory model | Efficient use of limited RAM |
Write the game once, compile to Z-Machine bytecode, run anywhere.
Technical Features
What the Z-Machine provided:
| Feature | Implementation |
|---|---|
| Text handling | String compression, printing |
| Parser | Tokenisation support |
| Object model | Rooms, items, NPCs |
| Variables | Local and global state |
| Stack | Subroutine calls |
| I/O | Platform-abstracted input/output |
Platform Support
Infocom released interpreters for:
- Apple II, IIe, IIc
- Commodore 64
- Commodore 128
- IBM PC and compatibles
- Atari 400/800
- Atari ST
- Amiga
- Macintosh
- TRS-80
- CP/M systems
- Many more (25+ platforms total)
Version History
| Version | Year | Capability |
|---|---|---|
| Z1 | 1979 | Original (Zork) |
| Z2 | 1980 | Improved |
| Z3 | 1982 | Standard Infocom games |
| Z4 | 1985 | Larger games (A Mind Forever Voyaging) |
| Z5 | 1987 | Beyond Zork features |
| Z6 | 1988 | Graphics (Zork Zero) |
| Z8 | N/A | Extended (community) |
Modern Relevance
The Z-Machine lives on:
- Inform 6/7 - Modern IF compilers target Z-Machine
- Frotz - Popular modern interpreter
- ZILF - Recreation of Infocom's ZIL
- Thousands of games - New Z-Machine games still created
Comparison to Modern Runtimes
| Z-Machine (1979) | Java (1995) |
|---|---|
| Write once, run anywhere | Same concept |
| Bytecode | Bytecode |
| Platform-specific interpreter | JVM |
| Efficient memory use | Garbage collection |
Infocom solved the portability problem early.
Why It Mattered
The Z-Machine enabled:
- Business model - One development, many platforms
- Quality control - Same game everywhere
- Focus - Designers could ignore hardware
- Legacy - Games still playable today
ZIL — the Z-Machine source language
The Z-Machine wasn't designed in isolation — Infocom built ZIL (Zork Implementation Language), a Lisp-derived authoring language that compiled to Z-Machine bytecode. ZIL gave authors a high-level vocabulary for adventure-game concepts (objects, rooms, parser routines) while the compiler handled the low-level bytecode generation.
The ZIL → Z-Machine pipeline pre-figures modern compiler / VM architectures:
- ZIL source files (
.zil) - ZILCH compiler → Z-Machine bytecode
- Z-Machine interpreter on target platform
- Game runs identically anywhere with an interpreter
This was the same architecture Java would adopt 16 years later (Java source → bytecode → JVM → run anywhere). Infocom solved the portability problem far earlier than the industry recognised at the time.
Inform — the modern descendant
After Infocom's demise (1989), the format was reverse-engineered by the interactive-fiction community. Graham Nelson released Inform in 1993 — a free compiler that targets Z-Machine. Modern developments:
| Tool | Notes |
|---|---|
| Inform 6 (1996) | C-style syntax; targets Z-Machine; still actively used |
| Inform 7 (2006) | Natural-language syntax ("The book is in the library."); targets Z-Machine + Glulx |
| Glulx | Newer VM by Andrew Plotkin; relaxes Z-Machine size limits |
| Frotz, Bocfel, ZMPP | Modern Z-Machine interpreters |
| Twine, ChoiceScript | Different tradition (web-native) but similar ethos |
Hundreds of modern interactive-fiction games target the Z-Machine — the IFComp annual competition has run since 1995, with Z-Machine games as a major category each year.