News for hackers. Stuff that matters.
Re:It's not what programming languages do, it's what they sh... by astrobe_ on Friday March 27, 2020 @08:28AM (#22702301)
Probably it takes a lot of experience to use both correctly. If we are talking about a small programs, no threads, no chances of reuse (no modularity) - in other words "Keep It Simple and Stupid" - then it is fine.

But KISS is difficult to achieve: there's Hubris that pushes you to do "powerful" things rather than getting the job done, there's "anticipatis" that pushes you to have an answer ready for all future changes instead of solving the problem you actually have now, there's deadlines, and there's invasions of external unwanted complexities (silly requirements, interfacing with buggy software/hardware...).

That's why generally speaking "don't" is the safe piece of advice. But those who think they have the basics down can try it (in a harmless context like personal tools) and see what happens for themselves.

Re:It's not what programming languages do, it's what they sh... by p_l on Friday March 27, 2020 @03:44PM (#22706120)
one example of good use of globals is for very light-weight pub/sub, where you keep the rule that only one place can write to the global (preferably with something like atomic write) and any other place only reads.
Re:It's not what programming languages do, it's what they sh... by DubiousPusher on Tuesday March 31, 2020 @08:05PM (#22744221)
I use this kind of blackboard system still when I can't avoid globals. The main thing it helps with I find is you still have to know the order of and when your systems are being setup.

Ran into so many bugs from people creating static instance globals and thinking it was good that they didn't have to care when systems were setup.

I hate create on access with a passion. For god sake just new the damn thing at the beginning of main if nowhen else.