From: James Tucker Date: 2010-08-30T21:25:25+09:00 Subject: [ruby-core:31945] Re: Proposal: Autoload with block On 30 Aug 2010, at 06:09, Nikolai Weibull wrote: > On Sun, Aug 29, 2010 at 23:52, Urabe Shyouhei wrote: >> (2010/08/30 5:23), Magnus Holm wrote: > >> Yes, and quite simply we (at least me) now consider autoloading a bad idea. > > Asking as someone who has switched to using autoload for basically > everything I write for Windows (work) because require is insanely slow > on Windows (especially on network shares) in both 1.8 and 1.9, can you > please expand on why you now consider autoloading to be a bad idea? Autoload is a bad idea if you're doing loads inside of a threaded environment, as it can cause double loads to occur (but not on MRI I think), and this can result in some code that is evaluated twice to have some unintended effect. It can also result in incomplete constants being used such as to cause unusual errors, for example, methods not yet being defined. The reality is, this is actually the same for any lazy load in a threaded environment. People seem to have taken the issue of autoload as if it is the cause of the problem, however, there is another opinion that the cause of the problem is allowing code to be loaded in a threaded environment. In my opinion (and a number of others) to load code in a threaded manner is fraught with potential issues that are hard to overcome, furthermore, the common runtime of most applications should be: Load (code) Setup (class heirachy, configurations, etc) Spawn (threads) Run (application logic) If users keep to good order, problems can be avoided regardless of loading mechanisms. I sympathise with your use of autoload, indeed I use autoload to save significant overhead in tests and such, and simply ensure that code is fully loaded and configured in any threaded production environment. Indeed a large part of the reason for subload[1] was to make it easier to override the loader semantics for production runtimes that would be threaded that could not ensure being fully loaded ahead of time. The solution worked very well there. [1] http://github.com/raggi/subload