Skip to content
sims1253Public

About

A reimplementation of the GNU R runtime in Rust: GNU R 4.5 behaviour, aiming to be faster

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

robigo

An experimental runtime for the R language, written in Rust. (Rōbīgō is Latin for rust.)

robigo aims to run unmodified R code with GNU R's exact behaviour — same printed output, same messages — and then to make it fast: a specializing interpreter, vector fusion, and type information from ry. See docs/design.md for the research behind it, the architecture and the roadmap, and AGENTS.md for the porting contract.

Status: early, but it runs real R code. The parser matches GNU R's on R's own library sources. robigo boots all of GNU R's base-package R code on top of 627 of R's 760 .Primitive/.Internal functions, starts up like R (Renviron, profiles, a locked base namespace), and loads installed packages from a GNU R 4.5.0 library through R's own loadNamespace: utils, stats, grDevices and graphics work today. robigo cannot load packages' compiled code, so native routines are ported to Rust (75 of stats' distribution functions plus 33 others, including R's formula engine, LINPACK QR, cov, glm families, read.csv/write.csv); a routine without a port raises an error saying so. lm, glm, summary, anova, predict, read.csv and write.csv give output identical to GNU R, and all 157 conformance scripts match byte for byte.

Not yet: S4 (methods), many stats routines (optim, integrate, fft, splines, ...), packages with compiled code beyond base R's, and locale-aware string collation. Closures and loops run in a register bytecode VM, hot loops as Cranelift native code; ROBIGO_COMPILE=0 runs everything in the AST interpreter and ROBIGO_JIT=0 turns off native code. ROBIGO_TYPE_PROFILE=out.json records observed types for comparison with ry (docs/ry-integration.md).

Progress

speed vs GNU R builtins GNU R's regression tests help-page examples FastR test snippets

Measured by CI on every merge to main (see docs/verification.md); every benchmark and corpus over time is on the progress page.

Speed of robigo relative to GNU R 4.5.0 over time

Share of each test corpus that matches GNU R 4.5.0 over time

Install

Nightly binaries for Linux (x86_64, aarch64) and macOS (aarch64, x86_64) are on the rolling nightly release (with SHA256SUMS.txt). Or install from git (Rust 1.99+, a C compiler; on Linux also zlib1g-dev libbz2-dev):

cargo install --git https://github.com/sims1253/robigo robigo-cli

Platforms, checksums, and the GNU R interplay are in docs/distribution.md.

Try it

cargo build --release
target/release/robigo -e 'f <- function(n) if (n < 2) n else f(n - 1) + f(n - 2); f(20)'
target/release/robigo script.R        # like Rscript script.R
target/release/robigo                 # REPL
target/release/robigo parse file.R    # parse tree in the oracle dump format

(The workspace may build into ~/.cache/cargo-target if your cargo config sets a shared target directory.)

Use in your project

Parse with robigo-syntax and compute with robigo-numerics from crates.io; embed the full runtime (a git dependency until it is publishable):

cargo add robigo-syntax robigo-numerics
cargo add robigo-runtime --git https://github.com/sims1253/robigo
let arena = robigo_syntax::Arena::new();
let exprs = robigo_syntax::parse_program(&arena, "1 + 1").unwrap();

let mut interp = robigo_runtime::Interp::new();
robigo_runtime::bootstrap::load_base(&mut interp).unwrap();
interp.run_source("x <- 1 + 1\n", true);

Details — library entry points, the crates.io table, and how releases are cut — are in docs/distribution.md.

How correctness is checked

GNU R 4.5.0 is the oracle:

  • tests/parse/ — parse trees compared with GNU R's parse(). Regenerate with scripts/regen-parse.sh; run the big corpus (R's own sources) with ROBIGO_PARSE_CORPUS=... ROBIGO_PARSE_DUMPS=... cargo test -p robigo-syntax -- --ignored.
  • tests/r/ — conformance scripts; stdout/stderr/exit status recorded from Rscript with scripts/regen-expected.sh. tests/r/passing/ is a ratchet (one marker file per script) of scripts that must keep passing.
cargo test                                             # everything
ROBIGO_CONF_FILTER=tests/r/basics ROBIGO_CONF_DIFF=1 \
  cargo test -p robigo-cli --test conformance -- --nocapture

Layout

  • crates/robigo-syntax — lexer and parser
  • crates/robigo-numerics — nmath and long double arithmetic
  • crates/robigo-runtime — object model, evaluator, builtins, printing
  • crates/robigo-core — object model and memory manager (G2)
  • crates/robigo-capi — libR.so, GNU R 4.5's C API (G2)
  • crates/robigo-cli — the robigo binary and conformance runner
  • rlib/ — vendored GNU R base-package R sources (GPL-2+)
  • docs/ — design notes (distribution.md for installs and releases)

License

GPL-2.0-or-later, like GNU R, whose sources robigo ports and vendors. The reference BLAS routines ported in crates/robigo-numerics/src/blas.rs are LAPACK's, under its modified BSD licence (LICENSE-LAPACK).

About

A reimplementation of the GNU R runtime in Rust: GNU R 4.5 behaviour, aiming to be faster

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages