Posted 16 April 2014 - 09:14 PM
The problem with 32-bit IDs in some cases (they work wonderfully in others) is that sometimes you don't have a single authority generating the numbers. If you need to generate a unique ID in two separate tools without any cooperation then UUIDs are a fantastic option that have incredibly low likelihood of collision and aren't as prone to human error as string names.
For things like in-game unique IDs that are generated by the engine and consumed only by that single game instance, a 32-bit (or smaller!) ID is just fine. Smaller IDs are actually preferable in some cases since you can use them as indices into arrays or at least have them be keys to sorted maps or hash tables.
You can even generate perfect hashes for static sets of data like entries in a packed resource file (by altering your hash seed and hashing all items until you get no collisions, then saving both the chosen seed and all the hash results; usually only takes a few iterations unless you're using a bad hashing algorithm, an especially small hash size, or an especially large number of values).
For save games, it can still be valuable to use something like UUIDs. Sometimes you need to be able to generate unique IDs without loading up an entire save game file to check for duplicates or determine a best "next" value (say, for large open world games where only a portion of the world state is loaded into memory at any given time). There are many solutions; UUIDs are one of them and an easy one at that.
If you need smaller values, a 64-bit random UID may still give you no collisions in practice; I've never seen or done the analysis. I've yet to see any actual performance problems with UUIDs when used correctly and with discretion, though, even when used for every resource and every game object and every component.
Generating a v4 UUID (just random numbers) is very quick, and with a good RNG is still globally unique for all practical purposes. A 128-bit RNG like SFMT can generate swaths of UUID source data quite cheaply. After generating the bits you just set a few of them to specific values to make the UUID RFC-compliant if you care about such things.