3 ms·
Autoloading is one of the many weird and painful parts of Rails that favors magic over reliable programs. In development mode, Rails autoloads files ad-hoc. Thi
by stevebmark 3y ago
Autoloading is one of the many weird and painful parts of Rails that favors magic over reliable programs. In development mode, Rails autoloads files ad-hoc. This means that as you navigate your website, you're loading new modules. And the Ruby community adores implicit metaprogramming, so the fundamental structure of your classes and data changes, and it's different depending on how you navigate your local website. We got some horrific non-deterministic errors in development that would require a local server restart to undo. It's really scary stuff.
This blog post is about a problem that shouldn't exist, and doesn't exit in any other modern language ecosystem.
- SkyPuncher 3y agoI really like rails, but the "convention over configuration" absolutely drives me up the wall. It creates a lot of situations that are challenging to understand when explicit references would solve the issue. One thing I very much like about JS (among other languages) is the explicit import system. You can walk the dependency chain up and down to figure out exactly where and why certain code is called.
- byroot 3y agoYour code is supposed to be loadable in any order. If not, you are doing something wrong and you could experience just the same issues without it. But if you don't like autoloading, you can turn it off with just `config.eager_load = true`.
- stevebmark 3y agoSure, code isn't supposed to do lots of stuff. Ruby and Rails just make it hyper-easy to make difficult to debug errors.
- byroot 3y agoAll I’m saying is that autoloading isn’t the reason.