« Globals underrated continued | Main | I Am Happy »

July 28, 2009

Comments

I have been combining the two types of globals you mentioned (things that happen to be global and things that are accessed globally) into the same thing. Ultimately, I don't care about things that happen to be global, because that implies you can change how they are created and accessed without affecting the behavior of other systems that use it.

On the other hand, I think that all global references ultimately become scoped in the long run. Even things like a debug logger; we are seeing a continuous drive towards making code more self-contained and composable, which means that implicit references that can modify behavior are becoming less and less maintainable.

main() is probably the only exception.

This Australian notation of yours is very close to standard practice among good developers I know.

Thread-safety via locks, however, is untenable at eight cores and beyond. On a three-core XBOX360 or a four-core PC, it can sorta work out.

At eight cores and beyond, one typically employs a "job system" that farms little tasks to cores. Each core has its own tiny local memory (aka cache) and communicates with other cores 1) ideally never 2) if you must, via a FIFO.

A FIFO enables the writing core to keep pumping out outputs for a while, even if the reading core is too busy to pick them up. and vice versa.

As for "natural" singletons such as "gGraphics," well already on PC, graphics state is becoming thread-local. As of DX11, There's not much global worth sharing anymore.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.