Zig-cookbook: a collection of simple Zig programs that demonstrate good practices to accomplish common programming tasks

Hi everyone,

I’m glad to share a new project I work on in recent week.

Currently it’s mostly based on a rust cookbook, but I hope to add more recipes specific with Zig in future.

Happy New Year in advance!
Keep on coding in Zig!

24 Likes

Quick suggestion for the SHA256 example: instead of reading the whole file into memory, read it by blocks (of the page size bytes, for example) and use the incremental functions to compute the hash: init once, update for each block, and final to get the hash.

6 Likes

Thanks. Would you mind open an issue or submit an PR?

Done: Make SHA256 example not read whole file into memory · Issue #30 · zigcc/zig-cookbook · GitHub

3 Likes

I think it would be better to create an issue or a discussion to list which recipes need to be added.

Since @AndrewCodeDev is doing Algorithm coding challenges Algorithm Translation Challenge 1: Symmetric Difference would it make sense to add the “winner” of these challenges to the algorithm section of the code book?

5 Likes

I’m not sure since the translation challenge is often about more complicated stuff while the cookbook is on more basic (but very useful) tasks?

1 Like

An answer could be simply creating an advanced cookbook section

Could call it Michelin Star recipes in Zig lol

4 Likes

It might be good to have an advanced algorithms section somewhere, but we dont have enough of those to include right now. Anyway we do need a more reliable resource to find samples in general. If you wanted to do a poll or something like that which involves voting, it might be more useful to have users vote on what samples need including. If you got enough responses you could use it to organize the TOC. i.e. somebody could submit that we need to cover “parsing JSON file” or “http simple router” in an open-ended fashion. And you could list what everyone already submitted to avoid duplicate entries. If somebody already listed an existing topic then other users could also vote that topic up to make it a higher priority

1 Like

I like that idea lol

1 Like

Had to look that up to get it. Nice! lol

1 Like

If you want to add recipes, just open a new PR, or open a issue if you’re unsure whether your solution is general enough.

Honestly its probably a copyright issue if it was called that lol

Zig-cookbook featured on Hacker News today

5 Likes