Zig and AI coding

Let’s try to keep a Zig angle here. With TypeScript AI can do quite a lot, with Zig out of the box it easily hallucinates or mixes different versions. Surprisingly simple fixes and resulting positive experiences have just been reported.

I’m currently wondering about the computational cost of pointing agentic AI to Zig documentation or standard library source code. Deepseek 3.1 or other Chinese open models would run locally on a $10k Mac were it not currently cheaper to use cloud services, but that agentic approach might not make sense if cloud subscription prices go up (all the services seem to be losing money) because waiting for it to call tools multiple times, parse the output and spend a bunch of thinking tokens costs someone money or time.

Is this sustainable and can we somehow do better while still using the latest Zig release? Or can we get still more bang for the buck from the agentic approach?

I’ve had a good experience with Claude and Zig. I tend to operate more in a “high level engineering mode” now instead of constantly being in the weeds with syntax. I do babysit the assistant and read every change, give guidance, discussion of approaches, branching and merging, and planning. There are some common mistakes Claude makes because of changes in 0.15.2. When I see mistakes that are repeated, I have Claude write a note about it in a cheatsheet, then @include it in context when needed. Overall, the zig approach to dev, especially leveraging the entire c/c++ ecosystem (which has a lot of training data) has made coding way better for me. Also, the fact that Zig is a hermetic environment, with all the source for the stdlib right where you’re using it is great for the assistant.

At the end are a couple examples of how Claude helped me create builds for a couple of what I would consider sizable projects. I would certainly not have known all the fiddly flags, #defines, and syntax to do this without a lot of googling, but Claude already knows all this and just spits out the right build changes by looking at the build errors. Converting code that is tied to MSVC to work with zig cc is something I’ve found especially cool.

As an experiment, try asking your assistant to analyze all of the allocations in your program, and identify opportunities to use arena allocators. This type of refactor is fairly trivial for an assistant, and has great benefits.

Cheers.

Aaron

4 Likes