> it seems pretty common for dynamically typed languages and pretty much entirely absent from statically typed ones
Counter-example is Go and init() function.
Interesting, I had no idea that existed! I still think there's a a difference between "here's a hook you can use to run stuff earlier" and "importing any module is fundamentally the same as running it as a script unless the module happens to use a special conditional to wrap stuff inside of" though (and I say this as someone who doesn't go out of his way to defend Go design decisions)
Also C++/Java static initialization, C# static constructors, or Rust global variable initialization, ...
Most languages have this feature Afaik
Static initializers in C++ - sometime ago I saw savings of some 400 ms (?) startup cost of initializing static strings from constants by moving it to some compile time thing.