3 ms·
I find myself sometimes wishing that Rust genuinely didn’t have globals. There are some things where it’d cause pain, and some places where I’m not sure what yo
by chrismorgan 8y ago
I find myself sometimes wishing that Rust genuinely didn’t have globals. There are some things where it’d cause pain, and some places where I’m not sure what you’d replace it with (lazy_static, for example), but I find that Rust actually makes it too easy to do globals and thus have unexpected side-effects (e.g. command line arguments, environment variables, working directory—I would genuinely prefer these things to be passed to main for me to use at my discretion), although in most places the culture is against using them, which saves it from being too much of a problem. Yet still, strict functional purity can open up some delightful optimisations and avoid various bugs, just like how putting error handling into the type signatures helps clarify things and avoid all kinds of bugs. I’d like to see what Rust would be like with even fewer, or no, globals.