Hacker News new | ask | show | jobs
by dudeinjapan 299 days ago
I still like Ruby. 15+ years in, I find myself in the camp of not wanting it to change. 25 year old me would have been totally jazzed about the addition of namespaces in Ruby 3.5/4.0. 40 year old me wants namespaces to get off my Ruby lawn.
2 comments

In your camp, waving a flag. I love ruby's simplicity when it comes to rapidly prototyping something, and find the wails about production type errors puzzling.

Only thing I've come near that gave me as much joy was Elixir, and I simply didn't have time to pick it up more than the most generic basics.

my mind just likes a.any? {|x| x.someCondition? }

Doesn't Ruby essentially already have namespaces, in terms of having modules? If one has proper modules, why would one ever need an alternative, weaker, concept for referring to things?
To make sure code loaded from gems doesn’t shadow the namespace of the application.
Right. Today Ruby has essentially a global namespace, where every defined module/class/const is put in the same "global dumping ground" and can override/"monkey patch" each other.

Ruby 3.5 will introduce a new language keyword "namespace" that scopes behavior to that namespace.

  class Foo
    def foo; puts "foo"; end
  end

  namespace Bar
    class Foo
      def foo; puts "bar"; end
    end

    Foo.new.foo #=> "bar"
  end

  Foo.new.foo #=> "foo"
Fun times.

This is intended for isolated code loading similar to "modules" in Python or ES6, but I am worried it will be abused badly. I'm also unsure whether they will add a "use Namespace" construct...

See here: https://bugs.ruby-lang.org/issues/21311