« Globals underrated continued | Main | I Am Happy »

July 28, 2009


Mat Noguchi

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.

Bryan McNett

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.

The comments to this entry are closed.

Jamie's Bragging Rights

  • Spider-Man 2
    The best superhero games of all time Game Informer
    Top five games of all time Yahtzee Croshaw
    Top five superhero games of all time MSNBC
    Top 100 PS2 games of all time Official Playstation 2 Magazine
    1001 Games You Must Play Before You Die Nomination for Excellence in Gameplay Engineering Academy of Interactive Arts & Sciences
  • Schizoid
    Penny Arcade PAX 10 Award
    Nominated for XBLA Best Original Game
    Nominated for XBLA Best Co-Op Game