What's everybody working on? (September Edition)

Demo thread! Share screenshots, videos, sound clips, stories, 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.

If you posted in a previous thread, give us an update! Are you tackling a new challenge? Still wrestling with the same problem space? Have you moved on to something completely new?

Previous threads:

So, what’s everybody working on lately? :slight_smile:

29 Likes

I am having a great time contributing to Cubyz. It may not be the best example of zig code, but it’s nice working on something with so many different areas of code to explore. Next month we can celebrate the 1 year anniversary of the 0.0.0 release.

Currently I am working mostly on the permission system for commands and the core system for accessories (after which you can hopefully finally heal in Cubyz!)

16 Likes

I am working on a lisp! I’ve always been interested in lisps and programming language development but I’ve never gotten past the basic arithmetic tree-walking interpreter stage for some reason. My first project in Zig was Crafting Interpreters so it only seems right that I actually finish something.

I want to learn about intermediate representations, ir optimization, and type systems so I’ve decided to do a bytecode vm. A lisp-like probably isn’t the best language to gather an understanding of static type systems but oh well hopefully I’ll learn something.

As for the vulkan renderer in my previous posts, I implemented a semi-functioning scene system and blinn-phong lighting. Then I got annoyed at attempting to turn the semi-functioning scene system into a functioning scene system and lost motivation. I’m proud of myself though because that’s the farthest along I’ve gotten in a project before and I learned a lot about vulkan. I’ll probably pick it up later again when it piques my interest.

6 Likes

BytePool

I implemented Io.Writer in my project, which seeks to behave similarly to Writer.Allocating.

Each List (a u32 reference to a dynamic array) can be made to implement Io.Writer with a call to BytePool.setSink(), creating an ephemeral allocating writer instance.

The implementation relies on a custom data structure that manages the memory and pools the allocations of many dynamic arrays.

Implementing Io.Writer was just these three functions, which I believe I have defined correctly here:

This is all to make the serializing of self referential structures simple, as nodes can reference each other by u32 and allocations are stored densely.

Is it exactly practical? Maybe. Useful? I think so. Was it fun to mess with? Absolutely.

4 Likes

I’ll chip in with the driest and most boring thing in the thread:

Documenting EU regulatory compliance for the embedded Linux application I develop at work.

(If anybody has resources for SBOM generation in Zig or with the Zig build system, I’m all ears. Working with Yocto is making me want to tear my hair out after more than a year being entirely Zig-native)

18 Likes

For the past few months, I’ve been working full-time on a long-standing frustration of mine: I want a performance/behavior profiler natively designed around non-linear execution flows.

By non-linear, I mean any software that has to detach itself from the strict LIFO order of native threads and callstacks: asynchrony/concurrency, events loops, queues, M:N scheduling, coroutines/fibers/etc, any form of distributed compute, any form of batching… Basically, anything multiplexing compute, I/O, data, or all of the above.

Another way to think about this is in terms of execution spans. In traditional LIFO systems, child spans start and end neatly within the scope of their parents. In heavily multiplexed systems, spans may…:

  • Outlive their parents, or any of their ancestors
  • Share zero temporal overlap with the context that spawned them
  • Arrive out of order
  • End up seemingly orphaned
  • Unintentionally stall or never finish at all
  • Seemingly finish before they even started (yes)
  • Any combination of the above
  • Etc

Inspecting these systems through the lens of a native thread is usually not useful at best, and often actively harmful at worst (i.e. sends you on wild goose chases). What matters is the logical execution flow, not the physical one.
Right now, we have tools like perf and Tracy on one end of the spectrum (legitimately incredible for LIFO, but fall short on multiplexed flows) and high-level observability protocols like OpenTelemetry on the other (great for logical workflows, but designed for enterprise observability rather than profiling, meaning: heavy sampling, bloated SDKs, slow UIs, and generally a focus on aggregated patterns rather than raw data).

I want Tracy-level UX and performance, but built specifically for non-LIFO paradigms.
Crucially, It must also be great at detecting things that are not executing, or stopped doing so halfway through: IME, things that should be running and silently aren’t (a coroutine lost at sea, a queue that doesn’t get popped, purely userspace deadlocks and livelocks, etc) often turn out to be more damaging than active bottlenecks in these kinds of systems.

Here’s a screenshot from an early prototype, where Balamb is observing its own ingestion pipeline:

(This is Dear Imgui, although I do want to give DVUI another try when I get a minute – it seems to have made a lot of progress since I last looked.)

After months of exploring the problem space, wrestling with the core data model, trying many different things for the main data structures, and endlessly suffering through UI/UX design, I believe I finally have an architecture I’m happy with on all fronts. Now I just have to build it all :melting_face:.

Building on Zig has been incredible. Kudos to the team.

25 Likes

I’ve been working on programming an ECU, BMS and various sensors for an electric race motorcycle. I’m in a team of ~20 students builting a motocycle for the MotoStudent competition.

We’re using a few different types of microcontrollers and so far I have used Zig to target STM32 microcontrollers. I’m using ST’s hardware abstraction library directly with no issues. Inspired by TigerBeetle, I’m building a deterministic simulation test for the ECU. It has proven more difficult than I originally thought, but I’m getting there.

One of the few issues I encountered was that the objcopy from the build system produced binaries that were way to large (hundreds of Mos!) to flash onto the microcontroller. This issue is already tracked and I’ve mitigated it by using llvm-objcopy directly.

Most of the source code is private, but I’ve built a CAN database parsing library I can share. CAN is a message-oriented protocol typically used on vehicles that allows different components of that vehicle to exchange data. A CAN database (*.dbc file) is a proprietary file format that describes what are the messages, their “signals” (fields), how signals are encoded, which component sends them and receives them. I got tired of the database getting out of sync with the source code, so I made a library that ingests a *.dbc file in a build.zig and generates all the message definitions as well as encoding/decoding functions. So far it has been working flawlessly.

I also built a package that packages another project required to flash the microcontroller and can be used as a build step. So now, when somebody else wants in the team wants to program and flash an STM32, they have one less system dependency to worry about.

12 Likes

Making steady progress on Flyt, my re-write/port of GameMode to Zig.

Getting there with a functional baseline that has all the features I want for a 1.0.

This last month or so I’ve added:

  • Per-client configuration
  • Configuration from envars (that can also be files and raw ZON)
  • Ported over renicing, screensaver inhibiting and iopriority optimisations
  • Added basic automatic client detection
  • Improved config filters with globbing
  • Tons more improvements, zig learnings and more

Had tons of fun refactoring and trying out different constructs in Zig. I’m learning a lot about the kind of idiomatic code I do and don’t like, so it’s nice to have a playground for that.

Obligatory screenshot, though it’s not a GUI so have some logs:

One key part of my work here is to try and “roll my own” set of independent structs that fill the gaps left by std or allow me to avoid pulling in a dependency (and the issues that come with that). What that means is my src/util directory has a bunch of helpful standalone tools that others may find useful to copy from.

5 Likes

Working on a language/framework for live coding shaders, inspired by hydra (js) and a bit by tidal cycles (though only syntax-wise).

The biggest thing I want to improve on is integration with my system. hydra lives in the web browser, so it can be awkward to integrate audio feeds and video feeds. My ambition is to get editor support via LSP and allow one to just declare inputs/outputs, using autocomplete to connect things, a hypothetical example:

signal 'mic = fft 4 "Motu M4 Line In 1"

// Kinda hard on linux, need to look into portals...
image Editor = windowCapture "Alacritty"

// A triangle scaled by the loudness of the microphone,
// with editor overlay in an unnamed OS window
screen = shape 3 'mic[0] 'mic[3] . layer (luma 0.2 Editor) 

I got to collaborate with @jonrm to get started on audio input, which really helped me kick this back into gear.

Taking a short break to focus on a live coding performance this Friday, but excited to get back into it, and my goal is to perform in my own tool by the Spring/Summer.


My current, narrower interest on this project is setting up simulation testing for Wayland.

For the uninitiated, on Wayland is a communication protocol between a windowed application and the host (Linux) system. You can run the same application on different implementations of the windowing system, called Compositors, each with subtly different behavior.

It’s possible to have latent compositor specific bugs in your code!

My thought is: If I could fuzz my main loop with unique and deterministic interleaving of events between client and server, I could theoretically find issues like deadlocks much easier. However, it is potentially a daunting task: I’d have to mock the compositor interface to with enough juice to behave like a valid compositor according to the spec, and deterministically interleave server and client messages. So I’m taking some steps in that direction, building up some utilities (and also using them in other places). I expect it will evolve a lot through development.

9 Likes

rewriting my app to use dvui and sdl3 cuse the zig-sfml lib I was using was not updated in a long time

repo
edit: it’s a quran app

8 Likes

I am working my way into learning to code. I started with a post on Reddit and am working my way through the material. There is quite a bit to this and so it is taking some time. the steps were

  1. Read Code: The Hidden Language of Computer Hardware and Software
  2. Watch Exploring How Computers Work
  3. Watch all 41 videos of A Crash Course in Computer Science
  4. Take the Build a Modern Computer from First Principles: From Nand to Tetris (Project-Centered Course)
  5. Take the CS50: Introduction to Computer Science course.
  6. Grab a copy of C programming: A Modern Approach and use it as your main course on C.
  7. Follow this Tutorial On Pointers And Arrays In C

And there were a few more. I have also been trying to review code from some of the major Zig projects and the Zig std itself.

I think I am ready to try and make an intentionally over complex letter guesser game just to test out some of the stuff I have been reading about.

11 Likes

As part of another project I made myself a read-only SQLite VFS for use with @embedFile in WebAssembly projects. I way overcomplicated it before realizing that translate-c could do so much of the heavy lifting. It’s still very untested and janky, but so far it’s working for what I need.

3 Likes

I don’t know how detailed people like to read these, I thought I’d go in depth a bit more this time because I enjoy talking about this project. So here’s like a semi-dev vlog

GUI library

I finally finished the GUI library for my calorie tracker.

Making text work with clicking, scrolling and copy paste as well as highlighting was surprisingly hard (especially scrolling when you resize, what most browsers do if you resize the window is they throw your scroll into a position miles away from where you were, and avoiding that was non-trivial.)
I hope other people that had to solve this problem for immediate mode GUI will sympathize with my pain.
It’s a keyboard based app, but many people will want to use the click, and I didn’t want the mouse to just be dead.

output

Unfortunately the bottom of the window in this video is cropped, but it’s not too important, it’s just clickable for “abort” “help” or “exit”.

0.17 migration + Incremental

I also recently migrated the project to 0.17 dev builds, because 0.16 had some bugs that were fixed in master, and got to enjoy incremental compilation. That REALLY came in clutch when I needed to update the project to the new version of the GUI library, which made many breaking changes, I was fixing a ton of compile errors.

GUI design

Currently I need to finalize the GUI and add some new ideas I had about how to make using the parser faster.

I think GUI design is where I am getting very stuck. Showing this to people unfortunately gives you vague advise like “frendlier GUI” which I can’t really make something actionable out of. Asking some friends that actually program thankfully give you concrete talking points.

I think I’ll probably have to just accept the GUI as it is, and probably release a BETA and get feedback from people that actually tried to use the app.

The things that are needed before release are better colors (these are a placeholder) and of course, the chef costume for the plebosaur in the corner. I Was planning to add nutritional guides but that will probably have to wait after the beta.

Parsing

It’s something I call “implicit addition” basically for example if you were to type “100g weetabix 100g milk” it wouldn’t work in status quo, you would have to write “100g weetabix + 100g milk” which is unacceptable, as the ‘+’ is 1 keystroke that we can save.

The other thing is a better system surrounding portion sizes, I want to add default portion sizes, so basically for example “100weetabix” will convert to “100g weetabix” this will also save keystrokes, and it can also work with the fuzzy finder such that when you press tab to autocomplete it can add the portionsize.

The first version of the parser was a parser without an AST, however with these, to be able to format the user’s input, I ended up being forced to re-write it such that it uses an AST.

TLDR

10 months in a project I thought would take 1 month, it’s almost done.

19 Likes

I’ve worked on a bunch of different kinds of software, but a CRUD app has never been one of them, so I’m building a web application for RFC/RFD/ADR/whatever your favorite term is for “structured engineering review”. The tooling in this space is largely missing as far as I can tell.

7 Likes

Besides preparing for the Eurozig founding meeting and Zig Day Cologne (more on that soon), I’m currently working on a fork of Anyzig. It’s my favorite Zig version manager and did not see any updates recently. I’ve already updated most of the code to 0.16. Anyzig also contains half-finished support for ZLS. I want to move that over the finish line.

5 Likes

I reckon you’re done reading/watching for a while :sweat_smile: but if you’re still open to suggestions, I’d recommend CS:APP (aka “Computer Systems: A Programmer’s Perspective”). It’s one of the two books that i have the fondest memories of from my student days (the other being “The Elements of Computing Systems”, more colloquially known as… nand2tetris!).

Enjoy! I have such fond memories from this part of the journey :smiling_face_with_tear:

4 Likes

I’m having fun running Zig on an Arduino Uno R4 WiFi I got for my birthday recently (my partner did really well with this one!)

I was keen to get something up and running that was pretty much fully freestanding / no deps outside of the arduino bootloader on the RA4M1 (ARM Cortex based) microcontroller. Lots of reading data sheets, looking up address values, and forgetting to turn off write protection but I’ve progressed from getting LEDs to blink to controlling the charlieplexed led matrix and serial communication, with some minor abstractions, but all handwritten. I have little hardware experience and I have to say this is exceptionally satisfying!

5 Likes

I’ve been working on my own utility repl.

For things like unit conversions (lbs » kgs, m » ft’inch) viewing hex dumps with anotation, hex/endian conversions, etc. anything that would be useful to have at my fingertips so static linked zig binary I can just copy to any terminal I’m on.

Got a bunch of the actual functions working.
Now working on parsing the repl input to an AST so I can chain functions rather than just “FUNC ARG ARG ARG” so I can do something like lbs(100) + kg(100).

4 Likes

Depending on your preferred way of learning (commonly known as bottom-up and top-down), here’s another book I can recommend when you are in the bottom-up camp (even if it’s really old):
https://savannah.nongnu.org/projects/pgubook/

1 Like

Could you add support for mirrors, plz. I’m trying to update Zig right now, but it keeps failing on connection timeout. :sob:

2 Likes