It is also worth noting that Granny 2.x shipped out of the box with a generic C serializer that handled circular references, discriminated unions, endianness conversion, and version remapping for arbitrary data structures. And that was in 2002.
-
-
Replying to @cmuratori @Jonathan_Blow and
The only significant thing it doesn't handle well is references to structures inside other structures, e.g. you have a vec3 and elsewhere you have a pointer to the "y" component. This is something we discussed fixing, but it's a sufficiently rare case.
1 reply 0 retweets 3 likes -
Replying to @tom_forsyth @Jonathan_Blow and
Yes, and also dual interpretations it didn't handle (two pointers to the same thing that claimed to be different types). Both of these would be pretty easy to handle if you were trying to make a system that was meant to be a "standard" system people could use as a library.
2 replies 0 retweets 4 likes -
Replying to @cmuratori @Jonathan_Blow and
IIRC the first problem hurts execution time a fair bit because you're not just doing pointer equality comparisons, you're doing range comparisons. And speed was (is!) important. I guess we could have had two different serialisation paths.
1 reply 0 retweets 1 like -
Replying to @tom_forsyth @Jonathan_Blow and
But it also requires two traversals, which is even worse. So not supporting, or optionally supporting it, probably does make sense since it is almost never done.
1 reply 0 retweets 2 likes -
Replying to @cmuratori @Jonathan_Blow and
In ten years of using it in apps, I've only ever vaguely wanted this support twice. Once I worked around it with a pointer-to-start+plus index (it was an array), rather than direct pointer. The other time was actually a terrible idea once I thought harder about the problem.
1 reply 0 retweets 2 likes -
Replying to @tom_forsyth @Jonathan_Blow and
Yeah, I don't consider an actual problem with Granny's system, it's just interesting to think about how much speed you sacrifice if you want to support it...
1 reply 0 retweets 2 likes -
Replying to @cmuratori @Jonathan_Blow and
You could also annotate the pointers as whether or not they are this special type or not, so only do the expensive test for them. But it's still two passes for the whole thing even if there's only one pointer like that.
1 reply 0 retweets 1 like -
Replying to @tom_forsyth @cmuratori and
Oh - you could do a pre-pass of the TYPE system and "poison" that whole branch of TYPES. Then you make sure that branch gets done last. There will be cases (e.g. circular references) that can't be solved like this though. Then you still need two passes.
1 reply 0 retweets 1 like -
Replying to @tom_forsyth @cmuratori and
Never seen serialization work well when references were to isolated objects: a good reference refers to an array, and to an index in that array. e.g. "texture library FOO, entry #12" This at least keeps the door open to batch processing, which you eventually need anyway.
2 replies 0 retweets 8 likes
That is the way I do things these days as well, but usually for other reasons that have little to do with serialization.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.