2 ms·
It's something of an issue if you have some crate that needs to set itself up at load time without a call from main. But those are very rare. Even "simplelog" n
by Animats 4mo ago
It's something of an issue if you have some crate that needs to set itself up at load time without a call from main. But those are very rare. Even "simplelog" needs a call at startup to do anything.
- ameliaquining 4mo agoYeah, I think of avoiding the call from main as a devex consideration rather than a performance one, since either way the initialization code runs once at process startup.
- Animats 4mo agoI'm trying to think of any useful crate that really uses this. "Tracy", the profiling crate, used to self-start on loading, but that was changed to require a call to get it going.
- rcxdude 4mo agoBut it can cause problems when there's multiple crates trying to do it. If the call is explicit, the application developer can sequence the calls appropriately (or at least deterministically), as opposed to having the order determined by details of the implementation (something that was learned from the C++ 'static initialization order fiasco')