I've been learning Zig language. To master it, I've asked ChatGPT to give me 20 mini projects that will take me from beginner to advanced level. Below are the projects, I've organized from what it gave me.
A lightweight terminal calculator for quick arithmetic inside scripts.
- Accept exactly 3 CLI arguments:
<number> <operator> <number> - Supported operators:
+ - * / - Detect:
- Invalid numbers
- Invalid operator
- Divide-by-zero
- Integer overflow
- Print result to stdout
- Print errors to stderr
- Exit with non-zero status on failure
$ calc 10 + 20
30
$ calc 5 / 0
Error: DivisionByZero
- No floating-point support
- No interactive mode
Analyze logs or large text files efficiently.
- Accept filename as argument
- Output:
- Line count
- Word count
- Byte count
- Must read file in chunks (not load fully)
- Handle files > 500MB
- Handle UTF-8 correctly
$ zwc file.txt
Lines: 120
Words: 890
Bytes: 5600
- No colored output
- No recursive directory support
Efficiently build large strings (e.g., JSON, HTML).
- Struct:
- buffer pointer
- capacity
- length
- Operations:
- append(string)
- insert(index, string)
- delete(start, end)
- toSlice()
- free()
- Automatic resizing
- No memory leaks
builder.append("Hello");
builder.append(" World");
=> "Hello World"
- No Unicode validation
Load application configuration from file.
- Input format:
key=value
- Ignore blank lines
- Ignore lines starting with
# - Trim whitespace
- Validate known keys
- Return structured config
port=8080
debug=true
Produces:
Config { port = 8080, debug = true }
- No nested config
- No arrays
Process CSV exports from spreadsheets.
- Parse comma-separated values
- Handle quoted fields
- Handle escaped quotes
- Stream file (don’t load full file)
- Return rows iteratively
name,age
zig,7
Reusable resizable container for any type.
- Generic over type
- push
- pop
- get(index)
- resize
- free
- Double capacity strategy
var list = Array(i32);
list.push(10);
Alternative to dynamic arrays for unknown sizes.
- Generic
- pushFront
- pushBack
- remove(value)
- iterate
- free all nodes
Evaluate postfix math expressions.
- Read expression string
- Tokenize by space
- Use stack
- Support + - * /
- Detect malformed expressions
3 4 + 2 * 7 /
Result: 2
Fast allocation for short-lived objects.
- Preallocate block
- Serve aligned allocations
- Reset function
- Track used bytes
Structured logging for CLI apps.
- Levels: DEBUG, INFO, WARN, ERROR
- Compile-time disable DEBUG
- Timestamp
- Output to stdout or file
Search logs for patterns.
- Pattern string argument
- Filename argument
- Print matching lines
- Print line numbers
- Efficient scanning
Parse small JSON config.
- Parse objects only
- Support:
- strings
- numbers
- booleans
- Reject invalid JSON
- No external library
Learn networking fundamentals.
- Listen on port
- Accept multiple clients
- Echo messages
- Close cleanly on disconnect
Parallel job execution.
- Fixed worker count
- Job queue
- Submit jobs
- Graceful shutdown
- No race conditions
Speed up large file hashing.
- Split file into chunks
- Multiple threads
- Combine SHA-256 hashes
- Print final hash
Extend program without recompiling.
- Load shared library (.so)
- Known interface function
- Call function dynamically
- Handle load errors safely
Understand process control.
- Read user input
- Execute commands
- Support simple pipe (
|) - Exit command
Core of a text editor.
- Load file
- Insert at index
- Delete range
- Save file
- Efficient resizing
Extend text editor safely.
- Stack-based undo
- Stack-based redo
- Memory safe
- No leaks
Lightweight embedded database.
- CLI:
set key value
get key
delete key
- Persist to disk
- Load on startup
- Handle corrupted file safely
You will have built:
- Custom data structures
- Allocators
- Parsers
- Network servers
- Thread systems
- Plugin systems
- Storage engine
- Editor core