← All Game Engines

Z-machine

Infocom (Joel Berez & Marc Blank) · 1979 · 1970s · Zork Implementation Language (ZIL) compiled to Z-code

Infocom's virtual machine for interactive fiction, built in 1979 so a single compiled game could run on dozens of incompatible home computers — arguably the most portable virtual machine ever created.

The Z-machine was developed in the autumn of 1979 by Joel Berez and Marc Blank for Infocom, and it solved a problem that would define the early home-computer software business: fragmentation. Infocom wanted to bring its mainframe adventure game Zork to personal computers, but "personal computer" in the early 1980s meant a bewildering array of mutually incompatible machines — the TRS-80, the Apple II, the Atari 400/800, the Commodore 64, the IBM PC, CP/M systems, and many more. Rewriting each game for every platform would have been ruinous. The Z-machine's answer was abstraction: games were written in Infocom's Zork Implementation Language (ZIL), compiled to a compact bytecode called Z-code, and executed by a small interpreter — the Z-machine — that could be ported once to each computer. The economic logic was decisive. Instead of porting every game to every system, Infocom had only to write one new Z-code interpreter per platform, and its entire catalogue of interactive fiction would then run on that machine. Between 1982 and 1985 interpreters appeared for an extraordinary range of hardware — the Apple Macintosh, the Amiga, the Atari ST, MS-DOS, the TI-99/4A, the Kaypro, the Osborne 1, the DEC Rainbow, and roughly two dozen systems in total. Interactive-fiction historian Graham Nelson later called it "possibly the most portable virtual machine ever created." Over its active life from 1979 to 1989 the Z-machine evolved through six primary versions, each adding capabilities: better memory management, text compression to fit large games into tiny RAM, more sophisticated object handling, and expanded input and output. Text compression in particular mattered enormously, because it let Infocom pack sprawling parser-driven worlds and thousands of words of prose into the severe memory limits of the machines of the day. The Z-machine's influence outlived Infocom itself. Because its bytecode format was so well-documented and its design so clean, the interactive-fiction community reverse-engineered it and built modern tools around it: Graham Nelson's Inform language compiles to Z-code, and cross-platform interpreters keep decades of interactive fiction — both the Infocom classics and thousands of new works — playable on hardware their authors never imagined. Few pieces of 1970s software remain as directly usable today, and fewer still anticipated the write-once-run-anywhere philosophy that virtual machines like the JVM would make famous more than a decade later.

Notable Games:
  • Zork I–III (1980–1982)
  • The Hitchhiker's Guide to the Galaxy (1984)
  • A Mind Forever Voyaging (1985)
  • Trinity (1986)
Key Facts:
  • Built by Joel Berez and Marc Blank for Infocom in autumn 1979
  • Games compiled from ZIL to portable Z-code bytecode run by a per-platform interpreter
  • Interpreters were written for roughly two dozen incompatible computers between 1982 and 1985
  • Still in use today via Inform and modern interpreters — decades of interactive fiction remain playable