12 ms·
Is anyone aware of a language that simply does not have globals like this? Or globals at all? The more I deal with other people's code, the more I want one.
by Groxx 3y ago
Is anyone aware of a language that simply does not have globals like this? Or globals at all? The more I deal with other people's code, the more I want one.
Obviously there are some semantic-globals (ports, env, main thread, etc) that are unavoidable, but we have a way to deal with that: dependency injection. Allow it in main, everything else has zero access unless it is given the instance representing it.
Obviously that would be pretty painful in practice without some boilerplate-reducing tools, but... would it be worse in aggregate? Or would having real control over all this at last pay off? I'm quite curious.