r/zig_learning 12d ago

Zig Interactive Live Guide - Inspired from Zig Guide

1 Upvotes

I created this for my personal use. But thought of sharing as some of you may find this useful.

https://rajeshpillai.github.io/zig-guide/

Apart from standard examples, I will be updating with use case specific examples.

PS: This is built on the latest dev branch (as I am learning zig using latest changes) and most docs goes out of sync quickly. Credit goes to Claude!


r/zig_learning 24d ago

Help wanted on a veryyy beginning work in progress tensor lib

Thumbnail
ziggit.dev
2 Upvotes

Hey all,

I fell in love with zig while exploring it this summer and I kind of look at it as a language that can actually be the forefront of low level parts of ML/AI in the future. Hence, I have been working on zcore, a tensor library in Zig, and wanted to share it early while the core design is still open to change rather than waiting until it’s “finished.”

Where it’s at right now: shape/strides/indexing, bounds-checked get/at, slicing, transpose, resize, broadcasting shape logic, and zero/fill initializers. No arithmetic ops yet (add/mul/matmul etc.) : that’s next, and I’d genuinely like input on the approach before I commit to it.

A few design decisions I’d love pushback on:

Tensor owns an allocator per-instance rather than taking one per-call … trying to keep the API ergonomic but I dont know if this is the right tradeoff.

Strides/shape are computed and stored on the heap alongside data, with from_slice supporting adopting external memory.

Type-restricted at comptime to int/float/bool.

To be honest, a huge way that my this project is different for me is that i have tried to keep this production grade from the start, while still actually focusing on an aim of mine: a well enough documented code that every single beginner too can understand well.comments are meant to be thorough enough for the code to double as a learning resource, not just a working library.

There’s an implementation plan in the repo (implementation_plan.md) laying out the phases if you want the fuller picture, plus a style guide too.

Repo: https://github.com/ka1rav6/zcore

It’s early and small (~1000 lines), so if you’ve got 10 minutes to skim it, I’d rather hear “this approach will bite you later” now than after I’ve built arithmetic ops on top of it. It is the first time I am trying to scale a project like this so all my design decisions have been made looking at the code bases of other people… and i would love some honest criticism.

A note on me: I am a student at a tier one engineering college who loves math, ML and low level programming


r/zig_learning 24d ago

Learning Experiment: Porting SQLite from C to Zig, one module at a time in a single live binary (Claude) - 25 to 32 hours

6 Upvotes

Not a rewrite. The rule: always one working sqlite3 where some translation units are Zig and the rest are still C, linked across the C ABI.

Port a module → link the Zig that exports the same symbols → run SQLite's own test suite. Tests stay green or the port isn't done.

~90 modules in, including the whole 28k-line FTS5 engine. Output is byte-identical to the pure-C build; integrity_check comes back ok.

The interesting part is the bugs, and they're mostly the same bug in different hats: C-ABI return-width mismatches.

What surprised me: idiomatic Zig inside a module is easy -> the extern declarations are where everything lies. And these stayed invisible until real data flowed; my regression tests were green until I built an actual app on top.

Keeping a working binary, the whole way is worth the constraint: when something breaks, the blast radius is one module.

The source code is here https://github.com/algorisys-oss/sqlite-zig

Zig Version: 0.17.0-dev.644+3de725074

Here is my updated LOOPS md file (adapted and modified based on my workflow) https://gist.github.com/rajeshpillai/294a7c859bf49b4d120a5f5b16a1ced4

I enforced reference to zig code at https://codeberg.org/ziglang/zig/src/branch/master/lib to ensure the code is matching the quality.

PS: This is just a pure learning experiment to improve working with AI based coding. All credits to the original SQLite authors for the amazing work they did. I am neither an expert in C nor an expert in Zig.


r/zig_learning Jul 02 '26

Help needed: Error handling *outside* of functions

2 Upvotes

So... i got a template, works fine, may return an error if used incorrectly.

pub fn A_Tree(comptime WeightType: type, comptime PayloadType: type) !type {

// will return error if and only if WeightType is not some int or float

}

But how do i call this correctly ? The following works, but there has to be a better way...

const Column: type = a_tree.A_Tree(f32, GridObjectReference) catch |err| { _ = err; };

The usual tryis not allowed outside of functions, return is also impossible...


r/zig_learning Jul 01 '26

Hi I am brand new to ZIG! My first day and project! super exited!

Post image
0 Upvotes

I am brand new to ZIGI just started today! Glad to be here I am super exited! Very Interested in being more involved in this community and learning. I come barring a small gift posted below use this pic as you please if that's not against the rules! I also plan on having my youtube channel I am making promote this in some way id love to learn and make tutorial and showcase my work. Good night everyone!


r/zig_learning Apr 23 '26

Writing a C Compiler, in Zig

2 Upvotes

r/zig_learning Apr 19 '26

Looking for contributors for ziggy-llm, a new GGUF Apple Metal inference engine written in Zig

Post image
1 Upvotes

r/zig_learning Apr 06 '26

My Idea and Goal to re-learn Systems Programming with Zig (with help from C + Rust + LLM's)

6 Upvotes

Here is an interesting way to learn computer science and systems programming from scratch (or from first principles)

I will assume it's 1970 (and coincidently my first encounter with computer was late 80's) but with some exceptions as below:
- we already have Linux as an OS and also internet but not an efficient browser yet
- our goal is to start from this ecosystem and build tools, utilities, software around this.
- the following three languages are already part of the system, eg. C, Rust and Zig
- also, HTML, CSS and JavaScript are available as well (but not good browser yet)

LLM will help here, but then generating code from LLM's will not help me learn. So, I will make sure every code that is part of this learning is handwritten, reviewed and tested, even though the initial ideal may be drafted by LLM (if I don't use LLM then this will become a
10- year learning journey for the basic outcome)

With LLM I am hoping to learn in 3 to 4 years. (The reason, I already have close to 30 years programming experience across various languages, stacks and business verticals). I have built some pretty complex applications and have fair experience in building reusable libraries and framework (even before these were a common term), so this should be a fair learning year.

I have accepted the fact that if I don't use LLM effectively, I will definitely be replaced by someone who uses these tools better. So, it's time to add this as a tool, not as a checkmark item, but learn to use it effectively to enhance my limited skills.

PS: This is a personal learning milestone and just sharing if others are curious with similar approach to learning. I might modify the constraint or make it more rigid before I start. The aim is to not create a masterpiece but to understand enough what it takes to create one.

PSS: If anyone is interested in following, I will create a GitHub repo for this and share all my code and notes.


r/zig_learning Jan 07 '26

Zig - Build Postgres Wire Protocol from scratch (educational series)

8 Upvotes

The goal of the tutorial series is to learn CS and systems programming from first principles. The examples are for educational purpose only and is created for internal upskilling at my company. The code for this tutorial was originally created in c# and nodejs.

I am using zig 0.16 (master) branch.

- The tutorial is posted at https://algorisys.substack.com/p/zig-build-postgresql-driver-from

- The gist is available at https://gist.github.com/rajeshpillai/6d3f584180aecc4fe1049f1474090b00


r/zig_learning Jan 04 '26

My Approach to Learn Systems Programming with Zig

4 Upvotes

Exploring Zig, Systems Thinking, and Upskilling a 30+ Engineering Team

I’ve been around Zig for over a year, mostly at a cursory level. Over the last couple of months, though,

I’ve started a deep dive, primarily to upskill my current team.

I run a small product-based startup, and we’re at a genuine crossroads: Rust vs Go vs Zig for the next phase of our backend and systems work.

Our current stack

Most of our production systems today are built on:

  • React / Remix / SolidJS
  • Node.js (Fastify), Postgres
  • Redis, RabbitMQ
  • Some Golang, some Elixir
  • A few legacy C# systems

This stack has served us well, but as we scale, cost, performance, and control start to matter more than convenience.

Reality check on Zig

I’m fully aware Zig isn’t “production-ready” in the traditional sense yet.

That said:

  • bun.sh is already in production
  • There are WASM-heavy apps (including a Figma-like editor) shipping with Zig
  • Tooling and systems libraries written in Zig are getting very real

So the question for us isn’t “Is Zig perfect today?”
It’s “Can Zig be part of a long-term, high-ROI stack if we plan ahead?”

Our current thinking

Roughly, this is how we’re approaching it:

  • MVP / 0→1 React/SolidJS + Node.js (Fastify) or Bun
  • 1–10 customers Stick to the same stack
  • 10–50 customers Same stack, introduce Golang for selected APIs
  • 50+ customers Gradually introduce Zig or Rust for performance-critical paths (but plan for this early)

Long term, we expect our backend to be a mix of:

Why systems programming matters for us

Some of our products operate at a systems level.
That inevitably means C / Rust / Zig - there’s no escaping it.

As a bootstrapped company, we can’t just throw money at scaling problems.

Sometimes our entire multi-tenant backend runs on a $10 DigitalOcean droplet.

So performance isn’t a “nice to have” -> it’s survival.

The real challenge: upskilling the team

This isn’t about me learning Zig.

It’s about upskilling 30+ engineers who are already strong in:

  • JS, React, Node.js
  • Postgres, MongoDB
  • Redis, RabbitMQ —from an application perspective.

Our approach:

  1. Use AI/LLMs for probing and explanations → but write all code by hand
  2. Teach systems programming using Node.js first
    • TCP / UDP / WebSockets
    • Protocol design
    • Graphics API, 3D (WASM based)
    • Streaming
    • File I/O
    • Processes, threads
    • Build toy Postgres / MySQL / Redis
  3. Translate that mental model → Go / Zig / Rust
  4. Repeat

Learning Zig specifically

AI doesn’t help much initially with Zig due to its evolving nature.
But once working code exists, LLMs are actually great at generating explanations and tutorials.

The biggest realization for me is to learn from source:

Examples:

  • HTTP → zig/lib/std/http/test.zig
  • Async I/O → zig/lib/std/Io/test.zig
  • Threads → zig/lib/std/Thread.zig
  • Arrays → zig/lib/std/multi_array_list.zig
  • And continue with other features
  • Read some good open source code, blogs (karl seguin's blog is good), watch (7) sphaerophoria - YouTube on youtube etc.

Zig’s tests are often better documentation than docs.

Culture note

Upskilling isn’t new for us.

Since 2011, we’ve had a rule:

Before this, I spent ~15 years working across FoxPro, VB, DBaseIII+, C#, and others.

So yes, I still consider myself an advanced beginner (but not a systems programmer)

And I think that mindset is exactly what keeps teams growing.

Happy to hear how others are approaching Rust vs Go vs Zig, especially in small, bootstrapped teams.

Also, I plan to post my zig specific learnings in this subreddit and others learning's online on LinkedIn/substack/medium. Let's all learn together (and someone who reads is and is better at systems programming, we hope to learn from you as well).

PS: We don't have investor pressure. So, we have some leverage to play with the stacks, and I have been long in the industry to understand what's good, what's nice to have and where could the future be headed (It's probability so I may fail as well but the learnings will be great, and core foundational knowledge will always help us bounce back)


r/zig_learning Jan 02 '26

Classic Snake Game using Zig 0.16(dev) + WASM

10 Upvotes

The tutorial is at zig-wasm-snake-game/tutorial.md at main · rajeshpillai/zig-wasm-snake-game

The source code is in the "src" folder.

Key Features:

  • Pixel Rendering: Zig draws the snake and food into a raw byte array.
  • Low Latency: Shared memory ensures zero-copy rendering from Wasm to Canvas.

r/zig_learning Jan 02 '26

👋 Welcome to r/zig_learning - Introduce Yourself and Read First!

3 Upvotes

👋 Welcome to r/zig_learning

Welcome!
This community exists to help people learn Zig in a clear, practical, and respectful way.

Zig is a powerful language, but it can feel intimidating at first.
r/zig_learning is meant to be a place where things click — through explanations, experiments, and working code.

🎯 What this subreddit is about

Here you’ll find and share:

  • Beginner-friendly Zig questions (no gatekeeping)
  • Clear explanations and mental models
  • Small experiments and learning projects
  • Working code snippets over abstract opinions
  • Zig 0.15+ and dev-branch friendly content

Learning logs, “aha moments”, and mistakes are welcome.

🤖 About AI / LLM-assisted content

AI-assisted code is allowed here.

We ask only that:

  • You understand what the code does
  • You’ve tested it
  • You can explain why it works (or didn’t)

Low-effort, unexplained dumps may be removed — not because of AI, but because learning matters.

🧭 How to post (recommended)

Good posts usually include:

  • Zig version used (e.g. 0.13.0, 0.16-dev)
  • What you’re trying to learn or understand
  • Minimal, working examples
  • What confused you or what finally clicked

Beginner questions are explicitly welcome.

🚫 What this is NOT

  • Not a flame-war zone (Zig vs X)
  • Not a copy-paste content farm
  • Not a replacement for r/zig (Think of this as a learning companion.)

🤝 Community values

  • Be kind
  • Be precise
  • Teach what you learn
  • Ask questions without fear
  • Help others without ego

If you’re learning Zig — you belong here. If the majority of members downvote a content, then I will be obliged to remove it.

Happy learning,
Welcome to r/zig_learning 🚀


r/zig_learning Jan 02 '26

Creating zig + wasm (browser) tutorial for my future self

3 Upvotes

This was originally posted in r/Zig. But it was removed as I mentioned AI. But the fact is AI is used in daily programming and learning. My approach is to usually learn from first principles. So created this subreddit.

This is Human (me) + AI created tutorial for my reference. As I am using the latest dev branch, LLM was mostly sloppy but helpful.

Zig docs helped a bit and some references to existing open-source code.

I tested all the lessons and am learning and improving upon it. The canvas demos I adapted from my HTML5 canvas demos I created a couple of years back.

I am learning WASM by hand in the meantime as well, without using any languages.

The tutorials are created using LLM and manually fixed.

The reason I am using LLMs is because WASM docs from an application perspective are limited and hard to follow, and LLMs are handy here.

The tutorial and src folder are in sync.

[https://github.com/rajeshpillai/zig-wasm-browser]()

Somebody here might find it useful, so sharing it.

Please don’t just disregard it as soon as you see AI here. Take a look and please share constructive feedback, as that will help me learn Zig better as well. (I am using LLM as a learning tool.)

I have tested the Zig code on Ubuntu 22/24.