Zig Programming Language
Created:
The Zig Programming Language is an open-source programming language designed for robustness, optimality, and clarity.
Introduction
- Introduction to the Zig Programming Language - Andrew Kelley
- zig in 30 minutes; HN; Jan 2021.
- Learning Zig by Karl Seguin.
Code
- andrewrk/tetris: A simple tetris clone written in zig programming language.
- Hejsil/pokemon-randomizer: A Pokémon Rom randomizer tool written in Zig
- dbandstra / oxid · GitLab
Learning
Articles
Zig And Rust by Alex Kladov/
matklad
Ziggifying Kilo; Apr 2023.
When Zig is safer and faster than Rust; Mar 2023.
Problems of C, and how Zig addresses them; Jun 2023.
Why I am not yet ready to switch to Zig from Rust | by Pekka Enberg | Jun, 2024 | Medium
Why Zig Clicks; Mar 2021
- A small core
- tagged unions
- optionals
- automatic deserialization to structs
- type checked string formatting
- Local Reasoning
- Generics
- C interop
- RAII
- A small core
Project Management
FFI
- Andrew K: Friendly challenge for Go programmers:
Provide or link to a small (50-200 ish lines) idiomatic Go program demonstrating concurrency. (Elegant use of goroutines, channels, etc)
I’ll provide the equivalent Zig program using
async/await
andstd.event.Loop
for comparison.
My notes
Cross compiling zig
Code
# crosscompile.zig
const warn = @import("std").debug.warn;
pub fn main() void {
warn("Hello, world!\n");
}
Compiling natively on Mac OSX
$ zig build-exe crosscompile.zig
$ file crosscompile
crosscompile: Mach-O 64-bit executable x86_64
Cross-compiling for Linux
The C ABI tuple of (operating system, architecture, C compiler environment) is defined by --target-os --target-arch --target-environ
flags of zig. [ref]
zig build-exe crosscompile.zig --target-os linux --target-arch x86_64
Verify the executable file type created:
$ file crosscompile
crosscompile: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped