|
|
|
|
|
by hctaw
2000 days ago
|
|
> Why no love for global/static variables? I know they are prone to be misused Rust doesn't deal with "prone to misuse" but "provably safe, else explicitly unsafe, or made safe by the programmer through wrapping code." Global variables are inherently unsafe and need to be wrapped as such. Of course you'll need global state at some point in your life. What Rust does is yell to remind you that it isn't thread safe. If you stop thinking about a Rust program as a script where the runtime figures the hard stuff out for you, then these design decisions make a lot more sense. You have a lot more knobs to twiddle than in C#, no garbage collector, and no runtime. The compiler is pretty smart, but it tells you the things it knows and you're responsible for working around the limitations to create sound programs that the compiler can optimize. |
|