News for hackers. Stuff that matters.
Re:The V Programming Language is open source by sagichmal on Saturday June 22, 2019 @04:47PM (#20251657)
There is not a single situation where global variables are necessary.
Re:The V Programming Language is open source by holy_city on Saturday June 22, 2019 @05:48PM (#20251882)
Global logging in libraries is not uncommon, especially if you need to trap signals (which can only interact with global state).

COM APIs expose a global class factory as the main interface to a shared libraries.

Embedded systems and drivers require globals in one form or another.

"Globals are evil" comes from the fact that globals have side effects, and side effects make things hard, especially in modern software that utilizes asynchronous/concurrent logic. That just makes them unwieldy, not unnecessary. Especially when interacting with legacy systems that require globals.

Re:The V Programming Language is open source by crankylinuxuser on Saturday June 22, 2019 @04:57PM (#20251688)
I take it you've never programmed embedded?

Yeah, state sucks. But sometimes, you need a starting point, and diff from that. And, that's state.

One of the safe ways of handling global vars, is by having only a single non-interruptible function that can mutate global. And you have best make sure your global-mutating function is fast. You don't want to miss IRQs that might fire off but are blocked.

Re:The V Programming Language is open source by sagichmal on Saturday June 22, 2019 @05:18PM (#20251770)
Yes, embedded is enough of a special case that I don’t consider it as part of a general purpose discussion on programming languages.
Re:The V Programming Language is open source by mises on Saturday June 22, 2019 @07:11PM (#20252223)
Ericsson predicts 18 billion IoT devices by 2022. Those all need code written for them. Do you still consider embedded programming a "niche"? Maybe it's one specific case, but it's relevant and ought to be "part of the discussion".

https://www.ericsson.com/en/mobility-report/internet-of-thin...