- The paper introduces a novel Go-based framework that ensures high-precision stimulus timing and zero runtime dependencies for cognitive experiments.
- It leverages explicit garbage collection control and robust hardware synchronization to enhance stimulus presentation and accurate response measurement.
- Empirical tests on a Raspberry Pi 4 demonstrate sub-millisecond visual and audio precision, bolstering reproducible cross-lab experimental setups.
Goxpyriment: A Go-Based Framework for Behavioral and Cognitive Experiments
Overview and Motivation
Goxpyriment (2604.15245) proposes a novel experimental software framework implemented in the Go programming language, tailored for behavioral and cognitive research. The framework is explicitly constructed to mitigate several limitations prevalent in Python-based experiment control tools, such as platform-specific runtime dependencies, timing uncertainties stemming from garbage collection, and asset management complexities. Central to goxpyrimentโs architecture is the production of single, statically linked binaries that embed all necessary experimental assets and have zero runtime dependencies, thus streamlining both experiment deployment and reproducibility across heterogeneous laboratory environments.
Architecture and Technical Features
Goxpyriment centers its API on an Experiment object responsible for session management, safety-driven event handling (such as premature participant exits), and metadata logging. The programming model is designed to foster both clarity and flexibilityโa direct inheritance from frameworks like Expyrimentโwhile capitalizing on Go's static typing and error-checking guarantees. The Run callback structure ensures robust data preservation and hardware resource cleanup.
The framework integrates a customizable graphical participant information dialog, enhancing experiment setup efficiency and reducing the likelihood of configuration errors by allowing experimenters to specify parameters through a GUI or command-line arguments.

Figure 1: Example GetParticipantInfo dialogs for Retinotopy (A) and Number-Comparison (B) paradigms, demonstrating configurable participant input GUIs to minimize setup errors and support rapid experiment launch.
A key technical achievement is goxpyrimentโs explicit control over garbage collection. By leveraging Goโs ability to suspend the garbage collector during timing-critical trial loops, the framework eliminates a major source of timing jitter endemic to Python and JavaScript experiment libraries. Response collection is further enhanced by the use of hardware-interrupt-level timestamps retrieved directly from SDL3โs event API, yielding high-precision reaction time measurements and obviating the need for continuous polling.
For hardware synchronization, the framework employs go-sdl3 bindings, supporting VSYNC-based synchronization for visual stimuli, accurate tone generation, and serial/parallel trigger capabilities with TTL-level accuracy. Specialized streaming functions and "present stream" APIs enable precise delivery and verification of rapid, sequential stimulus presentations. The provided timing verification suite validates stimulus durations, frame-interval jitter, AV lags, and trigger reliability under real-world laboratory conditions.
Empirical Timing Characterization
The authors benchmarked goxpyrimentโs temporal precision on a Raspberry Pi 4, demonstrating sub-millisecond accuracy for visual, auditory, and hardware trigger stimuli. Visual stimulus presentation showed zero skipped frames and a frame lag (~32 ms) precisely matching two monitor refresh periods at 60 Hz, while audio lags (approximately 100 ms) were consistent and compensable. The consistency of stimulus and trigger delivery, as evidenced by tight standard deviations (โค 2 ms for visual, 6 ms for audio), validates the reliability essential for empirical research.
AI-Assisted and Human-Friendly Design
Goxpyriment is explicitly designed to interface harmoniously with AI-powered coding assistants, such as Gemini and Claude. The frameworkโs strong type guarantees, minimalistic and unambiguous Go syntax, and asset-embedding support mitigate common AI-driven coding errors, such as invalid API calls or file path mismatches. The manuscript illustrates how these features allow large portions of the template experiment gallery to be generated autonomously by LLMs, although human oversight remains necessary to address conceptual errors (such as mis-implemented stimuli).

Figure 2: Examples of AI-generated programming outputs, including typical errors such as misrepresentation of Kanizsaโs illusory rectangle and correct (rightmost) versus incorrect clock drawing responses.
Comparison with Existing Frameworks
Relative to Expyriment, PsychoPy, MATLAB/Psychtoolbox, and web-based tools (jsPsych), goxpyriment distinguishes itself through the following unique technical features:
- Zero dependency deployment: Complete portability via single-file binaries embedding assets and resources, compared to complex package management and interpreter requirements for Python- or MATLAB-based solutions.
- Explicit garbage collection control: Prevents timing perturbation during critical periods, dramatically improving timing fidelity compared to dynamic language environments.
- Unified hardware abstraction: Robust SDL3-based access to visual, auditory, and hardware trigger APIs.
- Static asset management: Through Goโs //go:embed functionality, stimuli and experimental assets are compiled into the executable, eliminating run-time dependency on filesystem layouts.
- AI coding support: The deterministic and statically typed environment yields significant advantages for projects collaborating with code-generating LLMs.
However, notable omissions in the current release include lack of support for video playback with frame-accurate timestamps, integrated eye-tracking APIs, and audio/video recording of responses. Additionally, web deployment (via WASM) is theoretically possible but not yet practical due to the immaturity of required toolchains.
Practical and Theoretical Implications
Goxpyrimentโs approach has direct implications for practical experimental reproducibilityโthe single-binary deployment model removes many failure points related to library version drift, asset path errors, and interpreter inconsistencies. This is particularly salient for cross-lab sharing and archival experiment re-use, satisfying an increasingly urgent requirement for open, reproducible science.
From the perspective of AI-assisted scientific programming, the frameworkโs minimal API surface and static guarantees provide an optimal substrate for LLM coding agents, reducing friction in automated generation and verification of experimental code. This positions goxpyriment as a reference architecture for next-generation experiment-control environments intended for hybrid human-AI programming teams.
Future development directions suggest rapid expansion into video playback, native eye-tracker and recording support, and ultimately, browser-based deployment as browser-side Go and SDL3/EMSCRIPTEN tooling matures.
Conclusion
Goxpyriment establishes a technically robust medium for behavioral and cognitive experiment programming, optimizing deployment reliability and temporal precision through the Go languageโs compiled nature and explicit control over system resources. Its architecture is particularly well-adapted to both human users and AI-powered agents, and empirical timing results substantiate its applicability for high-precision experimentation. Expansion of its capabilities to video, recording, and online deployment will further consolidate its relevance as a core tool for psychological and neuroscientific research.