logoalt Hacker News

assbuttbuttasstoday at 3:40 PM1 replyview on HN

Also C++/Java static initialization, C# static constructors, or Rust global variable initialization, ...

Most languages have this feature Afaik


Replies

ameliaquiningtoday at 6:25 PM

Rust doesn't have this behavior (sometimes called "life before main"). Code to initialize a static variable runs either at compile time, or lazily on first access, depending on which mechanism you use.

show 2 replies