Hello everyone,
I’m writing a 2d videogame in Zig with SDL. Though I’m quite experienced in most languages/technologies, I’m just learning zig, and was looking for up to date pointers for idiomatic use of language features/standard library in particularly two areas: memory management and I/O (Zig version baseline is 0.16). Do you have any such references? Googling it give me results for previous versions usually (I understand 0.16 is only two months ago, but still hope to find something).
These are great references, kudos to the authors and thanks for the references. Does something like this exist for allocators and memory management as well?
I think the language reference does a fairly good job at explaining allocators:
Not mentioned there yet is that some of the use cases described are now also covered by “Juicy Main” (i.e., you get a pre-initialized general purpose allocator and a pre-initialized arena):
https://ziglings.org is a wonderful collection of more practical exercises, including allocators.
Introduction to Zig is a book, so more explanatory, and has some projects that should show idiomatic code.
(eh looking at it, it does have some c-isms, like _ prefixed names, and does not follow naming conventions :/, and few non-trivial examples, but it is otherwise a decent book)
Hmm, we have a Docs section, which @Sze linked some posts from, that may have examples of idiomatic code relevant to the posts.
I would say not quite in the same manner, allocation is a pretty old topic that had only slow and slight changes over time, so most of the existing material is still relevant, but some parts have shifted over time, like for example names in the standard library: GeneralPurpouseAllocator -> DebugAllocator or using more data structures with an unmanaged style (allocating functions directly have an allocator parameter).
Also the Docs on this forum started mostly as filling holes in documentation that didn’t exist anywhere else.
I think regarding allocation and memory it is a big mixture of articles and links spread across the internet. @vulpesx already mentioned Ziglings and that is a great base for learning.
It would be very helpful if you let us know which resources you find that are up to date and relevant and helped you understand specific parts. (It is difficult to look at it from a beginner perspective after a while) Then we could try create a good overview document together or this topic can evolve towards that.
There are also a lot of topics on this forum about different specific aspects of memory-management
Because some of the older material will show dated main examples on how to get an allocator, make sure to take a look at the juicy main link @spiffyk posted.
@vulpesx and @Sze thank you very much indeed to both, I did already do the ziglings, and while I enjoyed doing them I think they are great as a first approach to the language but I was looking for something more in depth. The Learning Zig series seems to be what I was looking for, also the Zig Learning resources post looks juicy. Thank you very much indeed!