Demo thread! Share screenshots, videos, sound clips, asciinema recordings, link a blog post you made, or just explain what hobby project you’ve been working on lately. Ambitious, well-scoped, or anywhere in between, your efforts are welcome in this thread.
The original is by far my favorite thread on all of ziggit:
However I think it will be nice to make a new thread at the beginning of every month, because it gives people who already posted before to share updates, however small, and it encourages new people to join in for the first time.
I think that’s a very good idea to make a new thread at the beginning of every month!
I’m currently not doing that much stuff in Zig (at some point I’ll have to continue my OS programming though), but currently I’m building a (more or less) collaborative Forth for the web with a friend of mine.
The front-end has the Forth interpreter (of course I wrote everything in Vanilla JS) and submits the user input to the back-end (the back-end is written by my friend). Then, the front-end continuously asks the back-end for new input (from different clients). That way, all collaborators should get the input in the same order, and the client-side interpreter behaves the same on all clients.
It’s not ready to be shared yet, but we plan to make it public once the (client side) interpreter can do all Forth 2012 Core words and once my friend made sure the back-end is reasonably secure.
Also, the cool stuff about those crazy ideas is that it wouldn’t be fun to use LLMs for implementing them (and they are a nightmare, ethically); so I’m just spending evenings with implementing one or another word for the Forth 2012 Core spec/glossary and having fun.
I just released preuve.h is a simple and ergonomic unit tests framework.
While this project is in C11, it has been greatly influenced by the Zig project.
Other than that, I have a “research project” to better understand Zig’s concurrency and IO interface. If any of you have reading recommendations about concurrent programming, wait-free/non-blocking synchronization primitives and non-blocking IO, feel free to send them my way!
Posted this update on the previous thread a couple days ago, will repost here with some more info.
Project is a keyboard based cross platform calorie tracker in zig using Sokol I am staking my life on.
Currently, it’s actually functional and I love using it every day personally.
The Idea is you log what you ate with 100% accuracy in seconds if you try to go fast.
The GUI needs a lot of work, which is what I am focusing on now, but you can see a lot of the features working! (The over-engineered fuzzy finder which I could talk all day about, the syntax highlighting and error messages etc)
The font rendering on this demo is purely MTSDF, however I couldn’t make it look as good as I wanted for small font sizes.
I also didn’t want to take another dependency to do rasterization of .ttf files at runtime. Current builds have 7 bitmaps (8, 12, 16, 20, 24, 28, 32) and use bitmap font rendering for those font sizes, and MTSDF for the ones higher.
I Also need to find a corner to put my macsot (The dinosaur in my profile pic). I also need to give him a moustache, a hat and a spatula.
Supported platforms are Linux, Windows, Mac and WASM. The WASM version will be embedded in the website that will do the sales pitch.
If you go to any other calorie tracker, you have to accept cookies, answer a personality quiz, get an interview, make an account, maybe even give your credit card before you see how it looks.
With the WASM demo people can try it on the website and decide if they like it.
Data is saved on human-readable .txt files and I will at some point provide a library that parses it if people want to write their own stuff to work on those files, everything works offline.
I have been working on a suite of audio decoder libraries written from scratch in pure Zig and no reliance on C libraries, that will eventually be part of a larger project to bring them together under a single interface. The end goal is a library where you can just throw any common audio file at it, and read PCM samples of your preferred data type out without having to even think about the source format or encoding. Essentially libsndfile, but decoding capabilities only, and zero dependencies that weren’t built in-house.
Thus far, I have implemented FLAC, QOA, and WAV/AIFF (raw PCM, alaw, mulaw, MS-ADPCM, IMA-ADPCM, etc). My design goal is that each part of it as modular as possible, and can be used as a standalone and reusable component. For example, the IFF/RIFF container format is its own project, so can be used for both WAV, but also for SoundFont2 files when I eventually get to MIDI. The same goes for ID3 metadata, Ogg container, etc.
It is still in its early stages, but has been my labor of love for the past few weeks.
I started learning zig last month and I try to write a game as my first project using zig together with raylib and flecs.
Currently I’m trying to do map generation. I have a noise based map generator with varying temperatures. Everything is rendered by a custom tile map shader.
The map can be rendered in different resolutions.
This is a 262144 x 262144 tile map rendered on just 4 textures.
I have used a lot of languages. I have the most experience with java and go. Two years of experience with rust.
I had lot of fun so far writing code with zig. It reminds me of the time when I started programming with c, but without the big pain points.
The thing I really enjoy the most when working with zig is that I always know whether something is on the stack or on the heap.
I also like the leak detection with the allocator that is used in debug mode and in tests.
My goals for the next month or two is to improve the map generation, maybe place trees.
And create a better texture for the tiles!
And after that I want to add resources and buildings that harvest the resources.
Not sure how far I will come.
Edit: I was able to edit the other 2 images in after gaining trust level 1
Started with coding a “tuner” - calibrating about 100.000 heuristic values - to hopefully produce the next big boost for my chess engine. Have to dive into the math behind it now.
I’ve been working on a mandelbrot set renderer (yes very original), with a focus on deep zooms (beyond f64 precision) and responsive exploration. It renders on the GPU using vulkan, uses glfw for windowing, dear imgui for gui, gmp for reference calculation (high precision orbit to use for deep zooms via perturbation theory), and glslang for shader compilation.
The biggest accomplishment so far for me has been foviated rendering around the cursor, where the mandelbrot set is rendered in low detail at first and then in increasing detail starting around the cursor. The already rendered parts of the image are also preserved (and not recalculated) when moving around / zooming, so the max iteration bailout can be increased quite high before becoming laggy (~16,000 iterations on my laptop).
I’m currently working on improving the gui and adding more hot-switching of various parameters for a better testing/user experience.
I’m working on a embedded systems programming framework with std.Io implementation for async stuff. Kind of what Embassy is for Rust.
I’ve been working on it for ~1 month now. It isn’t ready for use yet (you can blink some LEDs in some boards though) and I’m aiming for supporting STM32s first (Arm Cortex-M).
So far I’m enjoying it very much. Specially learning Zig and Zig’s compiler more in depth and the std.Io interface looks neat at the moment.
I’ve mostly been working on preparing Flint for Zig 0.17.0, it’s been hard to do as much coding in my spare time as I’d liked because of the heat.
The biggest thing I needed to change was the build matrix I created which used custom build steps to build all permutations of each of the example projects (platform, optimization, internal/production). I ended up using addSystemCommand to run zig build for each of the permutations (commit).
I’m not sure if it’s the best approach, but it ended up being much simpler and since each projects build.zig file is used directly it’s easy to add this functionality to a project. All it takes is adding a new step and calling the buildMatrix function exported by Flints build.zig with the permutation settings you want, that function adds the system commands that build each permutation. Projects created using the new project generator are based on the template example, so they get this feature out of the box.
Unsure if it’d be of any use to you, and at this point it’d need to be updated for the new Reader interface, but in my experience metadata parsing can be a bit messy for tags found in-the-wild so maybe some of the implementations/ideas could be helpful.
code-wise, I just learned how to self-host my static sites (in such a way that should i ever host non-static ones, that’ll be fine too!)
I daylight as a math researcher, and if you’ll forgive me for going slightly off-topic, I have two fun updates to share. The first is this paper, which is fresh onto the arXiv, and classifies homeomorphism groups of compact, countable ordinals up to “coarse equivalence”. I wrote a blog post that introduces you to thinking about ordinal numbers and their topology.
The paper is quite cool, because 1) we get a complete classification for the entire family into only 3 buckets, which are actually buckets we previously identified in a paper last year, and 2) we have very concrete models for how to think of each bucket. The prettiest one is the collection of infinite-length binary sequences with finitely many 1s, equipped with the Hamming distance (count how many entries are different).
There’s an odd footnote about LLMs where despite not really finding them useful in my own practice, a small piece of the paper was suggested to us by somebody prompting an LLM based on our preliminary results. Not a story for today, I guess.
You’re looking at an “irreducible train track map” (a self-map of an undirected (multi-)graph with nice properties) whose transition matrix is cooked up to have characteristic polynomial
x^12 - x^7 - x^6 - x^5 + 1
whose largest root is sometimes called Lehmer’s number and is a particularly small example of a Salem number.
What’s exciting to me about this is that with collaborators, I feel like I now have a much clearer handle on how to make examples of train track maps with prescribed number-theoretic properties in this way. In particular, my collaborator who’s a grad student at Temple has Sage (Python) code that can more or less go from that polynomial and some other data and spit out candidate maps very quickly! And the algorithm is clear enough that I can work bits of it by hand!
Hmm, yeah that might be of interest based on a quick look.
The entire ID3 family is a travesty against humanity, I have no clue how such a terrible format became the de-facto standard for so long. I actually have a small start on an id3 package, just enough to realize it wasn’t as trivial as i first thought with the all the idiosyncrasies between versions, etc. It was quickly moved towards the end of the my todo list.
Thank you though, I will definitely take a deeper look when i get the chance.
Forgive my ignorance, I don’t know much about fractals other than being fascinated by them. How are you rendering this from a technical standpoint? Is it a quad (or multiple quads) showing the results of a shader or is there something else going on?
You will definitely hear from me about this project once I finish the thesis Deadline is in 2 week so wish me luck hehe (edit: and now as soon as i posted this i realized i forgot about ast in the first diagram…)
I’ve got a “working” lemmings game, called lemmingz (trademark ). It’s a simulation, not a decompilation, Full of bugs. My goal is to port it to wasm and allow for collaborative gaming through a browser.
tangential constructive criticism
I'd also say the diagram doesn't really help conceptualize the idea unless you're already familiar with it (colors would help, or some other way of denoting the fields are the same between AoS/SoA but where they are in memory is different).
This week I’m experimenting with writing some minimal bare metal firmware for the embedded ARM chip we use at work. We normally use C, but I wanted to get a feel for what it would look like if we were to use Zig.
I want to point out how absolutely impressed I am with the codegen modern compilers are capable of. In src/mmio.zig, I have some facilities for working with the MMIO[1]. Specifically, in the RWReg.rmwFields function I do some comptime magic to create an ergonomic API for atomic modifications to packed structs.
I generate two “shadow” structs for the original packed struct: one is visible to the callers of the API, where they can select which fields are going to be modified; the other shadow struct is for generating masks over the original packed struct. The code does some mangling between all three struct types – assignments, masking etc. I then use that API in src/gpio.zig in the Pin.configure function, picking between two fields of a struct based on whether an index is odd or even. All that struct mangling logic compiles into two simple conditional bit shifts, which is what you’d expect to have to write manually if you wanted this logic to be efficient. I realize the heavy lifting on the optimizations is (probably?) on LLVM’s side, but that makes it no less impressive. Combined with Zig, this is just so great – we could have code that is performant and readable AND pleasant to write!
Now “only” to convince my colleagues to switch
Memory-mapped input/output – for those not in the embedded world, the microcontroller basically has some specific memory addresses which are not for data storage, but instead, by reading/writing them you can make the chip do specific things. E.g. by writing some bits in registers for GPIO, you can turn voltage on/off on a pin, allowing you to control things outside of the chip (the most basic use case can be lighting up an LED, but there are much more complex things you can do with this of course), or you can measure voltages on pins etc. ↩︎
As mostly a programmer by hire with a late bloom into programming as a hobbyist I’ve never had the time to dedicate to learning game programming.
So I’m using a presentation I’ll have as an excuse, I’ll be talking about event driven systems and the plan is to use raylib to create a presentation deck, with the main use case of raylib to create some cool animations and even mini games for the presentation!
If you go to NDC Techtown in Konsberg, Norway let’s grab a coffee!