slime wrote: ↑Sun Dec 27, 2020 12:54 am
Lua's garbage collector is incremental
Oh hey, that's good info. Didn't know that. Mitigates the issue a little bit. Still, the collector has to collect an equal amount of garbage produced - sooner or later. The longer the game runs, the sooner that moment approaches.
pgimeno wrote: ↑Sun Dec 27, 2020 3:29 am
handle strings as tables of numbers. [...] That amount of wheel reinventing as a workaround to avoid generating garbage falls in the "nearly impossible" category, if you ask me.
I disagree. My fonts are custom sprite sheets anyway, so I'm rendering characters one by one anyway. Iterating through an array drawing characters isn't "nearly impossible" at all, it's basic programming.
Do you use like, font fonts in your game? Isn't authoring font files far more laborious?
Felix_Maxwell wrote: ↑Sun Dec 27, 2020 3:46 am
how to structure everything in a way that doesn't stress the system [...] macro-optimisations that just generally make games run faster.
The computer is at its most efficient when data is both
linear and
homogenous.
Linear, meaning, the data it needs next is located directly after the data it accessed last, i.e. an array. When you access table[1], the computer predicts you'll need table[2] next and pre-loads it from memory for faster access. If instead you access elements randomly, the computer makes bad predictions and you'll have a cache miss, at worst, for
every access.
A cache miss to a computer is like you trying to drink milk and discovering that your refridgerator is empty, and you have to go all the way to the supermarket to get milk. It's molasses growing uphill in January slow.
Homogenous, meaning, all the data it's going through is of the same structure. This is a little more involved in a dynamic language like Lua, because tables of tables are
not homogenous. So when the computer is iterating through an array of tables, it needs to "stop and consider" the structure of each table separately. This is why you hear game devs talking about "structs of arrays (SoA) instead of Arrays of Structs (AoS)". It means, having two arrays
xs[n] = number and
ys[n] = number may be faster to iterate through in unison than a single array
xys[n] = {number, number} (for e.g. game object coordinates in the game world).
Felix_Maxwell wrote: ↑Sun Dec 27, 2020 3:46 am
Love is able to run any reasonably-scaled game without running into garbage collection problems, if that's what you're asking.
I'm new to the community; could you link me to one you think fits that description to study?
I note that you downgraded your adjective from "giant" to "reasonably-scaled"...