New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
101: More details for SoA vs AoS #348
Comments
I think it's very difficult to explain the principles of Zig's "data-oriented design" in an exercise, but luckily there's a good video by Andrew Kelley that I can recommend: https://vimeo.com/649009599 In the case of the exercise, it is faster and uses less memory to use the arrays this way because the indices of the arrays are paired instead of address pointers for each value. But honestly, I don't know how we can describe it better. Maybe after watching the video you will have a good idea. 😉 |
Since then, I have also watched the same video :D |
Good idea I will see how I can implement it. |
I opened a pull-request on how I would shortly introduce it :) |
Add link to DoD talk in 101_for5.zig #348
Add link to DoD talk in 101_for5.zig ratfactor#348
Hey,
I read the comments in 101, and I am having trouble understanding the very last bit:
ziglings/exercises/101_for5.zig
Lines 117 to 121 in 9d6f1e2
I feel like I am missing an example for the last bit.
I understand the Array-of-structs part, as it should be something like
[]Character
with:from exercise 51.
And, as mentioned in the comments, it is something that feels natural to me.
But now, how would the struct of arrays be implemented or rather used?
I can see in the code above, what is meant by having multiple arrays for each data type, but I am unsure about how this would be actually used.
I also find this:
confusing. Shouldn't it be a single RPG characters struct ?
As far as I understood it, the idea is to use a single struct for all RPG characters and use arrays for each type and imply that a single character just means that the length of the arrays is 1, or put differently, that the single character case is a special case of the
Characters
struct (if this makes any sense :D )IMHO, it would be nice if the comments were more explicit and show the Character struct + array of the Character struct again for an explicit example of the AoS case and an example for the SoA case.
Maybe even with a function that prints the latter?
I think with a calling/function example, I would have an easier time understanding how data-oriented design would be implemented.
Sorry for the long issue, I am just trying to convey what I (an absolute zig n00b) have trouble with and hope that it might help others in the future. :)
The text was updated successfully, but these errors were encountered: