Beetle is a virtual machine designed for the Forth language. It uses a byte-stream code designed for efficient execution which is binary portable between implementations. It has been implemented in C (see below) and assembler. The C implementation should run on any POSIX system; the assembler version runs the supplied Forth compiler at up to half the speed of the corresponding native code compiler and generates more compact code. Beetle is designed to be embedded in other programs; a simple debugger has been written to demonstrate this ability. In the C implementation, all memory references are bounds checked. A standard I/O library is implemented; access to native code routines is also possible, allowing Forth and C programs to call each other.


These are papers I have written about the Beetle Forth virtual machine and the associated pForth Forth compiler, which I developed for my BA dissertation project. (I used to refer to it as a “virtual processor”; I now use the now-standard term “virtual machine”.)

An Introduction to the Beetle Forth Virtual Processor
An introduction to the system; this is the best paper to read first. It was published in ACM SIGPLAN Notices February 1997.
The Beetle Forth Virtual Machine
The design of the Beetle Forth virtual machine is described. This is an implementor's guide, but it's probably also useful to programmers.
An implementation of the Beetle virtual machine in ANSI C
A portable ANSI C implementation of Beetle is described, with instructions for porting, compiling and running it.
A simple user-interface for the Beetle virtual machine
A user guide for a simple debugger shell for Beetle.
Beetle and pForth: a Forth virtual machine and compiler
My BA dissertation containing all the papers mentioned above, as well as a description of the project that produced them.
Tradeoffs in the implementation of the Beetle virtual machine
A hand-coded implementation of Beetle is described, and compared to the C version.
Encoding literals in a portable byte-stream interpreter
Various methods of encoding literal numbers in a byte stream are compared.

Program (github repository)

This is the source distribution of C Beetle. Email me if you have problems getting it to work.

  • Source and documentation: tar.gz 1.45Mb (includes hand-optimised ARM interpreter plus binary for RISC OS)

Last updated 2017/05/11