5 ms·
While I agree that OP's complaint is valid, I think they're wrong in blaming the autoloader for it. If you were to remove the autoloader and to explictly use `
by byroot 5y ago
While I agree that OP's complaint is valid, I think they're wrong in blaming the autoloader for it.
If you were to remove the autoloader and to explictly use `require` in your app, when you `require a` if `a` also `require b`, you implicitly get access to `b` at the same time.
So the problem isn't the autoloader, but Ruby's and PHP single global namespace.
If anything the autoloader makes it easier to locate the source, because it forces you to follow a strict naming convention. If you see `Foo::Bar`, you know it's defined in either `foo/bar.rb` or `foo.rb`, and it's easy to locate with your editor fuzzy finder.
Another proof is that Django doesn't have this problem even thought it has an autoloader (IIRC).
I'd be very much in favor of a Node or Python like import system for Ruby, but there's nothing wrong with the autoloader.
- shime 5y agoThere are not a lot of things from JavaScript that I would love to see ported to Ruby, but ES6 imports is one of them.
- eyelidlessness 5y agoI’m not a Ruby dev so I can’t comment on that. But I can say that ESM truly is great, although it’s something many don’t appreciate until it finally clicks. I didn’t see the benefit over say CJS for a long time. It was the static analysis potential that finally made it seem so valuable to me. But being URL based (including data URLs!), idempotent, and extensible (eg type assertions) are also huge benefits.
- qudat 5y ago> So the problem isn't the autoloader, but Ruby's and PHP single global namespace. Interesting point and I agree! The thing I like about python and javascript's import system is you import the object that you end of using, creating a namespace as a variable, defined at the top of every source file. This lends itself to traceability which was my primary argument in the post. I can see how I conflated the global namespace in ruby with automatically loading classes. Cheers!