Skip to content

Why pure Go

Why pure Go

go-ruby-set/set reimplements Ruby’s Set in pure Go, with cgo disabled. The slice of Ruby it covers is deterministic and interpreter-independent: given its inputs, the result is a pure function of those inputs — no live binding, no evaluation of arbitrary Ruby. That is exactly the part that can — and should — live as a standalone Go library, separate from the interpreter.

Extracted from rbgo, reusable by anyone

This library began life inside go-embedded-ruby’s rbgo — in the prelude/internals that back the Ruby surface. It has been extracted into a reusable standalone library so that:

  • any Go program can import github.com/go-ruby-set/set directly, with no Ruby runtime;
  • the dependency runs the other way — an interpreter binds this module as a native module (the pattern go-ruby-yaml still follows), rather than this module depending on the interpreter. rbgo did so from 2026-06-29 until rbgo#330 reimplemented Set inside the interpreter for MRI 4.0 conformance on 2026-08-08; the library stands on its own either way, which is the point of extracting it;
  • the behaviour is pinned by a differential oracle against the system ruby, independent of any one consumer.

Why pure Go matters here

Because the library is CGO-free, it:

  • cross-compiles to every Go target with no C toolchain, and links into a single static binary;
  • has no dependency on the Ruby runtime — the dependency runs the other way;
  • can be differentially tested against the ruby binary wherever one is on PATH, while the cross-arch lanes (where ruby is absent) still validate the library itself.

See Usage & API for the surface and Roadmap for what is in scope.