Go + Computer = goputer
A computer emulator/virtual machine that intends to demonstrate how basic computers work at a low level.
Contents
- Features
- Documentation & getting started.
- Project layout
- Build instructions
- Development
- Credits
- License
- Custom assembly language and compiler.
- Custom runtime.
- Standalone executables.
- Frontends to show VM output.
- A WASM based runtime that runs in a web browser.
- Expansion modules written in Lua.
- IDE for easy development.
- High level language.
See the project wiki or try the playground at goputer.oscarcp.net.
frontendsContains source for the frontends.frontends/webThe WASM frontend.frontends/gp32The Go frontend.frontends/goputerpyThe Python frontend.examplesA list of example code to get started with.cmd/goputerThe CLI tool for compiling, running & disassembling code.cmd/launcherThe GUI for running code.pkgShared code. Includes the compiler, VM runtime and constants for instructions and registers.expansionsSource code for all of the default expansions.
Build instructions exist for Linux and Windows (amd64). The project should compile for MacOS as well however this hasn't been tested.
If you have Docker installed, you can build goputer in Docker without installing additional dependencies by running:
./docker_entrypoint.sh
This will build the container and then run mage dev inside the container, outputting to the build directory.
Note: This uses a Fedora container, so the output will only work on Linux based systems.
Partial cross compilation targeting Windows systems can be done on Linux, see Windows.
Perquisites
For Node I would recommend installing NVM (Node Version Manager).
Tested on Fedora 42.
mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel libXxf86vm-devel
mesa-libGL-devel wayland-devel libxkbcommon-devel
gtk3-devel golang golang-tests python3
alsa-lib-devel
Building (For Linux)
-
Install the prerequisites that are mentioned above.
-
Check that everything works.
$ node --version v22.13.1 $ mage --version Mage Build Tool <not set> Build Date: <not set> Commit: <not set> built with: go1.24.5 $ poetry --version Poetry version 1.1.13 $ go version go version go1.24.5 linux/amd64 $ python3 --version Python 3.13.2 -
Clone the repository from GitHub
git clone https://github.com/sccreeper/goputer cd goputer -
Activate the virtual environment for Python (unneeded if not using or building the Python frontend):
eval $(poetry env activate)
-
Build the project. (This step shouldn't take that long depending on your hardware)
mage buildAlternatively you can run
mage dev frontend.gp32,expansion.goputer.systo only build thegp32frontend. -
Go to the build directory and run the
hello_world.gpexample.cd build ./goputer run -f gp32 -e ./examples/hello_world.gp
TLDR;
- Windows executables can be built using cross compilation on Linux (run
build_win.sh). - mingw must be installed, in addition to the prerequisites listed under Linux.
- The gp32 frontend will cross compile however the goputerpy one will not, this is because pyinstaller does not support cross compilation.
- MSYS2 is the recommended compilation environment if you are compiling on Windows and targeting Windows.
- You may not be able to compile the web frontend on Windows.
- Install MSYS2.
- Once in MSYS2 (mingw64) install the required packages:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-go mingw-w64-x86_64-nodejs mingw-w64-x86_64-python mingw-w64-x86_64-python-poetry mingw-w64-x86_64-python-certifi mingw-w64-x86_64-python-pip mingw-w64-x86_64-pyinstaller git - Install mage:
Note: You may need to set those environment variables again.
export GOBIN=$HOME/go/bin export PATH=$GOBIN:$PATH go install github.com/magefile/mage@latest - Clone the repository:
git clone https://github.com/sccreeper/goputer.git - cd into the repository and install dependencies:
cd goputer poetry install npm install - Build:
Optionally run
sh ./build_win.sheval $(poetry env activate)if building the Python frontend as well. This output the location of the virtual environment activation script.
The result typically be in C:\msys64\home\username\goputer\build.
In addition to the dependencies in Building, you should also have golangci-lint (V2) installed.
There a small suite of tests written for testing the core of goputer.
To run them use:
go test ./tests -v
- Lua runtime - Shopify/go-lua
- The Lua runtime used by expansions.
- Raylib Go Bindings - gen2brain/raylib-go
- Very useful rendering library.
- See also: Raylib - raysan5/raylib
- Beep - faiface/beep
- Used for producing sound on the fly.
- TOML - BurntSushi/toml
- Configuration format used by frontends.
- See also: TOML - toml-lang/toml
- pygame - pygame/pygame
- Used for rendering & sound output.
- numpy - numpy/numpy
- Used partially for sound generation
- poetry - python-poetry/poetry
- Very useful for Python dependency management.
- Tailwind CSS - tailwindlabs/tailwindcss
- CSS library used to build the UI.
- Parcel - parcel-bundler/parcel
- Module bundler.
- Parcel Static Files Copy - elwin013/parcel-reporter-static-files-copy
- Used for copying static files into the final dist directory.
- Bootstrap Icons - twbs/icons
- Icons used heavily by the UI.
- Microtip - ghosh/microtip
- Tooltip library used in UI.
- Mediabunny - Vanilagy/mediabunny
- Used for recording and muxing MP4 files
- Zip.js - gildas-lormeau/zip.js
- Used to create and load ZIP archives
- Dexie.js - dexie/Dexie.js
- Used for interacting with IndexedDB.
- Comlink - GoogleChromeLabs/comlink
- Used to provide a easier interface between the worker/runtime and UI threads.
- CLI - urfave/cli
- Used by the compiler for getting input from the terminal.
- Color - fatih/color
- Used for colouring & formatting the terminal output i.e. making it look nice.
- Termlink - savioxavier/termlink
- Inserting links into the terminal.
- Tview - rivo/tview
- Used for the profiler UI.
- Fyne - fyne-io/fyne
- UI library used
- dialog - sqweek/dialog
- Used for file open dialogs.
- Mage - magefile/mage
- Build system used for development.
MIT - Refer to the LICENSE file
