Ruby 3.5 Feature: Namespace on read
Published on: 2025-07-15 07:39:34
Description
This replaces #19744
This proposes a new feature to define virtual top-level namespaces in Ruby. Those namespaces can require/load libraries (either .rb or native extension) separately from other namespaces. Dependencies of required/loaded libraries are also required/loaded in the namespace.
This feature will be disabled by default at first, and will be enabled by an env variable RUBY_NAMESPACE=1 as an experimental feature.
(It could be enabled by default in the future possibly.)
The "on write" approach here is the design to define namespaces on the loaded side. For example, Java packages are defined in the .java files and it is required to separate namespaces from each other. It can be implemented very easily, but it requires all libraries to be updated with the package declaration. (In my opinion, it's almost impossible in the Ruby ecosystem.)
The "on read" approach is to create namespaces and then require/load applications and libraries in them. Programmers can con
... Read full article.