- Tokenizer: An exercise that started about something simple but it ended up teaching me a lot about array and pointer sizes and optionals.
- String Literals: I wanted to understand better how string literals work and some interesting things about slices and arrays.
- String concatenation: Some example to do string concatenation. It's probably better to use a library like https://github.com/JakubSzark/zig-string but it's good snippet to have around when I just want to do something simple
- General purpose
- Page allocator: According to some video, this and the one above are probaly the easiest but the slower to use.
- Fixed Buffer:
Don't know why yet but I cannot make a "big" allocation with this one.I could not make a big allocation with the fixed buffer because I was passing a buffer array created on the stack, not on the heap. See this conversation. - Arena
- Arena with fixed buffer
- Allocators and Syscalls An example of the syscalls made to the underlying OS Linux to request memory with the output of
strace
- Generic Struct
- Generic Sum function
- Traits (sort of): An exercise examining the use of io.Writer and the kind of structural typing to can do to have "traits".
- TCP client TCP client that sends a single message.
- TCP server TCP Server that listens for incoming connections.
- Redis client Toy Redis client using Redis protocol
- TCP Ping Pong TCP server that sends a message and listens for an incoming response.
- Simple Async/Await A simple async/await example with sleeps without external pieces like the example below.
- Async/Await A clone of TCP Ping Pong with async/await.
- Parsing strings or bytes buffers Examples of parsing number in text
"1234"
into int1234
and bytes arrays into known numbers. - Tokenizer Small tokenizing exercise that ended up as a nice memory allocation exercise.
Files that start with c-*.*
# messages like "Double of 4 is in C 8" should appear in stdout
make libfunction
- c-main.c A simple main function in C just to see how it is done in plain C
- c-libfunction.c A very basic C library to load as a shared object
*.so
- c-libfunction The zig code that calls the
*.so
shared object that I created in c-libfunction.c
# a request is made and the plain HTML printed into stdout
make curl
# NOTE: I need to download raylib to make this work. I placed it in ${HOME}/software/raylib
# a window with a hello world message should open
make ray
- c-ray Interop with the Raylib library (https://github.com/raysan5/raylib)
At the moment of writing this README, the documentation is outdated and the header file is not generated as stated in the docs. The workaround is to write the headers manually. Look at files c-double_me*
for examples:
## Passing 8 in the c-double_me.c file
make c-double_me
16
- example.txt To use in the file_read snippet
- slow_server.go A TCP ping-pong server in Go that takes 2 seconds to respond (to play in async and test the Network snippets)