Tuesday, May 13, 2025

The Digital Press

All the Bits Fit to Print

Ruby Web Development Artificial Intelligence
Urban Planning
Astronomy

Ruby 3.5 Introduces Experimental Namespace on Read for Isolated Code Execution

Ruby 3.5 introduces "Namespace on read," an experimental feature enabling virtual top-level namespaces to isolate libraries and dependencies within the same process, controlled by RUBY_NAMESPACE environment variable.

From Hacker News Original Article Hacker News Discussion

Ruby is introducing an experimental "namespace on read" feature allowing virtual top-level namespaces that isolate loaded libraries and their dependencies, preventing conflicts and enabling multiple gem versions in a single process. The feature is enabled via an environment variable and aims to allow safer co-existence of code with overlapping names or incompatible dependencies.

Why it matters: This feature tackles common Ruby issues like conflicting global constants, unexpected shared state, and gem version clashes within the same process.

The big picture: The namespace model differs from traditional sub-interpreters by sharing a single GC heap and offering weaker isolation, raising questions about long-term viability and parallelism.

Stunning stat: Early benchmarks show about a 3-5% overhead in interpreter performance with namespaces enabled, with some crashes still being fixed.

Commenters say: The community is divided; some praise the bold innovation and potential, while many raise concerns about complexity, performance impact, unclear real-world use cases, and prefer sub-interpreters or process-based isolation.