Zig
Ziglings is nice for learning.
TigerBeetle & Bun have great Zig code to study.
This talk was great for tips on writing performant Zig code that minimizes allocations.
OSS Zig GUI apps
- Pixi - Cross-platform open-source pixel art editor and animation editor.
Notes
- Zig compiler pipeline is: tokenize -> parse -> astgen -> sema -> codegen
- Automatic error unions, required error handling, errdefer, and the try keyword really give Zig my favorite error handling feel of any language.
- Types are values in zig, this means that to create generic functions you pass the type as an argument and change the function logic based on that. This is also possible thanks to another feature, running code at compile time with comptime.
- Zig has good "surface area minimalism". comptime is just one keyword, but it replaces the entire C preprocessor (well, mostly), a template/generics system, type reflection, and probably a few more things. Same with the build system: I don't need to learn a separate language to describe builds, instead the build system is (mostly) just a stdlib module. It's true that the Zig's error handling, tagged unions, slices, etc... are "less minimalistic" than C, but those things exist to fix obvious problems of C in a way that would be hard to do in libraries, and because of this they are justified.
- Most significant optimization that zig enables is stack backed allocators. Allocators being passed around in function calls, a third party library that allocates stuff doesn't have to know where the data is allocated. It's up to the client code to chose what allocator they provide, effectively allowing stack-only allocations, even in third-party code.
Links
- Zig Learn (Code) (Code)
- The Road to Zig 1.0 - Andrew Kelley (2019)
- Pluto - Hobby x86 kernel written in Zig.
- Hobby x86 kernel written with Zig (HN)
- Zig Compiler Internals (2020)
- bootstrap-zig - Start with minimum system dependencies and end with a fully operational Zig compiler for any target.
- Zig 0.6.0 Release Notes (HN)
- PBUI Project - Standard library toolsets in the Zig programming language. (Code)
- A Brief Exploration of Zig (2020)
- zls - Zig LSP implementation + Zig Language Server.
- zls: A Zig Language Server - Alex Naskos & Auguste Rame (2020)
- Why Zig When There is Already CPP, D, and Rust? (Lobsters)
- Zig: a great fit for emulators - Benjamin Feng (2020) (Lobsters)
- What is Zig's “Colorblind” Async/Await? (2020) (Lobsters)
- Zig Showtime - Show where members of the Zig community share code and ideas.
- Announcing the Zig Software Foundation (2020) (HN)
- Zig Live Coding: Self-Hosted Incremental Compilation Debug Info + LLVM 11 Upgrade (2020)
- Awesome Zig
- Awesome Zig 2
- Zig Learning & Usage Guide
- Interview with Zig language creator Andrew Kelley (2020) (HN)
- What is Zig's Comptime? (2019)
- Zig's New Relationship with LLVM (2020) (HN) (Lobsters)
- Zig Compiler September Update & Hot Code Swapping Brainstorming (2020)
- Advanced Hello World in Zig - Loris Cro (2020)
- Zig heading toward a self-hosting compiler (2020)
- Assorted thoughts on zig (and rust) (2020) (Lobsters) (HN)
- Is Zig the Long Awaited C Replacement? (2020) (Lobsters)
- zigup - Download and manage zig compilers.
- Zig Spec
- Pirates of Apple Silicon - Jakub Konka, Frank Denis, Andrew Kelley (2020)
- Zig in 30 Minutes (HN)
- Extending C with Zig
- Why Zig when there is already C++, D, and Rust? (HN)
- Zig Makes Go Cross Compilation Just Work (2021) (Lobsters)
- Ziglings - Learn the Zig programming language by fixing tiny broken programs. (HN) (Stream doing Ziglings)
- Zig Docs
- Zig Roadmap 2021 (Lobsters)
- Why I rewrote my Rust keyboard firmware in Zig: consistency, mastery, and fun (2021) (Lobsters)
- Memory-mapped IO registers in zig (2021) (Lobsters)
- Zig, Parser Combinators - and Why They're Awesome (2021)
- How (memory) safe is Zig? (2022) (Lobsters) (HN) (HN) (Lobsters)
- Zig Playground - Online Zig compiler inspired by Go and Rust. (Code)
- zigdoc - zig -> docs.
- zig.run - Run and play with Zig source code. (Code)
- An intro to Zig's integer casting for C programmers (HN)
- Performance Tracking for Zig
- Building an efficient and portable programming language with Zig (2021) (Lobsters)
- Zig Makes Rust Cross-compilation Just Work (2021) (HN) (Lobsters)
- setup-zig - Use the Zig compiler in your Github Actions workflows.
- Corecursive: Andrew Kelly Built Zig (2021) (Reddit) (HN)
- Zig wrinkles (2021) (Lobsters)
- Zig pathtracer (2021) (HN)
- Async engines in C++20, Rust, & Zig (2021)
- Android Apps in Zig - Contains a example on how to create a minimal Android app in Zig.
- Looking into Odin and Zig (2021) (HN)
- Maintain It with Zig (2021) (HN) (Lobsters)
- ziglint - Linting suite for Zig.
- Resource efficient Thread Pools with Zig (2021) (HN)
- Zig News
- Code Coverage for Zig with Callgrind (2021)
- Fuzzing Zig Code Using AFL++ (2021) (HN)
- Building gamedev ecosystem for Zig
- Asserting function signatures at compile time in Zig (2021)
- Mach Engine: The Future of Graphics (With Zig) (2021) (HN) (Code)
- Andrew Kelley, Lead Developer & President of the Zig Software Foundation (2021)
- zig-snapshots - Preview Zig's incremental linker state in interactive HTML.
- Zig LSP - LSP implemented in Zig.
- Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot (2021) (HN)
- Zig monthly - Once-a-month publication where I curate all things Zig.
- zig build explained (2021)
- A Practical Guide to Applying Data-Oriented Design - Andrew Kelley (2021) (Lobsters)
- The ZLD Linker (2021)
- Interfacing with Zig, a BDFL-run project (2021)
- Nix flake for Zig
- Zig Compiler Internals
- Allocgate: Restructuring how allocators work in Zig (2021) (HN)
- List of Zig Gamedev Projects
- Minimal build.zig for targeting iOS
- Zig 0.9.0 (HN)
- What do you think about Zig? (2021)
- A Review of the Zig Programming Language (Using Advent of Code 2021) (HN)
- A Comparison of Rust and Zig (HN)
- Analysis of the overhead of a minimal Zig program (2022) (Lobsters)
- Zig Strings in 5 minutes (Lobsters)
- Failing to Learn Zig via Advent of Code (2022) (HN) (Lobsters)
- Let's build an Entity Component System from scratch in Zig (2022)
- Using Zig to Build Native Lua Scripts (2022)
- Zig by Example (Code)
- Zig Compiler Internals (HN)
- Is Zig faster than Rust?
- Why use Zig over Rust/Go (2022)
- ziglibc - Exploration on creating a libc implementation in Zig.
- Using Zig as cross-platform C toolchain (2022) (HN)
- ZigSelf: An implementation of Self in Zig (Lobsters)
- zigtool - Go tool of the zig compiler automatically compiles different targets according to the GOOS GOARCH environment variable.
- Hot-code reloading on macOS/arm64 with Zig (2022) (HN)
- wazm - Web Assembly Zig Machine.
- Looking at Zig Programming Language (2022) (HN)
- I Believe Zig Has Function Colors (2022) (Lobsters) (HN)
- Zig Bit Twiddling Hacks
- Zig self-hosted compiler can now build itself (2022) (HN) (Lobsters)
- Zig interpreter written in TypeScript
- Zig Web Code
- Getting Started with Zig on the Raspberry Pi Pico
- Minimal example showing how HTML5's canvas, WASM memory and Zig can interact
- Uber Uses Zig (2022) (HN) (Lobsters)
- Zig PyPI distribution - Zig programming language, packaged for PyPI. Lets you run Zig code from Python easily. (Tweet)
- Mixins in Zig (HN)
- Learn Zig by examples (Code)
- Paid Zig Stream (2022)
- Testing Zig for embedded development (2022)
- An Intro to Zig's checkAllAllocationFailures (2022)
- Zig Common Tasks - Collection of Zig code snippets for some of the most common tasks.
- How to get started with Zig? (2022)
- Zig is becoming more production-worthy (2022)
- Zig Language Server (zls) for VSCode
- Some Thoughts on Zig (2022) (HN)
- Makin' wavs with Zig (2022) (Lobsters)
- Running Zig with WASI on Cloudflare Workers (2022) (HN)
- Self Hosted Compiler Upgrade Guide (Tweet)
- Packed structs in Zig make bit/flag sets trivial (2022) (HN) (Lobsters)
- A Practical Guide to Compile Time Evaluation - Alex Naskos (2022)
- Revisiting the design approach to Zig (2022) (HN)
- Zig, the Small Language (2022) (HN)
- Tree Sitter For Zig - Zig's Tree Sitter based on Zig Spec Official.
- Building a Tiny Mutex (2022)
- Virtual tables with zig-sqlite (2022)
- Nix Flake for Zig
- What Makes the Zig Programming Language Unique? (2022) (HN)
- Zig-style generics are not well-suited for most languages (2022) (Tweet) (HN) (Lobsters)
- List of Zig Gamedev Projects
- That Time I Tried Porting Zig to SerenityOS (2022) (Lobsters)
- Mach engine & core examples
- Ziglibc: Sweeping out the rug from underneath C - Jonathan Marler (2022)
- Zig Is Self-Hosted Now, What's Next? (2022) (Lobsters) (HN)
- Zig's I/O and Concurrency Story - King Protty (2022)
- Distributed Zig with Elixir and Zigler - Riccardo Binetti (2022)
- A minimal RocksDB example with Zig (2022)
- Zig 0.10.0 Release Notes (HN) (Lobsters)
- Simple Scalable Unbounded Queue (2022)
- Easy Interfaces with Zig 0.10.0 (2022) (HN)
- Goodbye to the C++ Implementation of Zig (2022) (HN) (Lobsters)
- Using Zig for Advent of Code (2022)
- What I learn by implementing argparser in Zig (2022)
- Zig Aarch64 Disassembler
- zdb - Simple debugger in Zig for Zig.
- A Zig Diary (2023)
- Thoughts on Zig (2023)
- 3 things you might like about Zig (2023)
- Why a linker author had to write a YAML parser in Zig (2022)
- Zig Meta Programming (2023)
- How a Zig IDE Could Work (2023) (HN)
- nix-zig-stdenv - Zig based cross-compiling toolchain.
- Zig Bits: Returning slices from functions (2023)
- Multi-Object For Loops + Struct-Of-Arrays (2023)
- Smoking Hot Binary Search In Zig (2023)
- Prime Reacts: Is This New Language Better Than Rust? C++? (Zig First Impressions) (2023)
- Zig's Curious Multi-Sequence For Loops (2023) (HN)
- When Zig is safer and faster than Rust (2023) (Lobsters) (Reddit)
- All Algorithms implemented in Zig
- Zig: The modern alternative to C (2023) (HN)
- Writing JSON to a custom output in Zig (2023)
- The curious case of a memory leak in a Zig program (2023) (HN)
- Errors and Zig (2023) (HN)
- Zig is FASTER and SAFER than Rust | Prime Reacts (2023)
- Zig Quirks (2023) (HN)
- Zig And Rust (2023) (Lobsters) (Reddit)
- Zig Build System (2023) (Lobsters) (HN)
- libuv, but multi-threaded, but not really (2023)
- Ziggifying Kilo (2023) (Lobsters)
- Mastering project management in Zig (2023)
- Regular Expressions in Zig (2023)
- Deep Neural Networks from Scratch in Zig (2023) (Lobsters)
- SIMD with Zig (2023) (HN)
- Bootstrapping Uber’s Infrastructure on arm64 with Zig (2023) (Lobsters)
- My Zig Experience | Prime Reacts (2023)
- Zig Data Structure Katas (2023)
- Using Zig | My Initial Thoughts on Zig (2023)
- zvm - Install/upgrade between different versions of Zig.
- I think Zig is hard but worth it (2023) (HN)
- Testing in Zig (2023)
- Zig Language Server And Cancellation (2023) (HN)
- Zig dangling pointers and segfaults (2023)
- A Note About Zig Books for the Zig Community (2023) (Lobsters)
- Metaprogramming in Zig and parsing CSS (2023)
- Rust vs Zig for writing a language
- The Seamstress Event Loop In Zig (2023)
- File for divorce from LLVM (Lobsters) (HN)
- Problems of C, and how Zig addresses them (2023) (HN)
- Bazel build rules for Zig
- Publishing Diagnostics From Three Years of ZLS - Auguste Rame (2023)
- Zig helped us move data to the Edge. Here are our impressions (2023)
- Parsing timestamps and generating RFC3339 dates in Zig (2023) (Lobsters)
- Proficient Parallel Programming - King Butcher (2023)
- Commiting Type Crimes in Zig (2023)
- Zig 0.11 (2023) (HN) (Lobsters)
- Error Handling in Zig (2023) (HN)
- How to Use Abstraction to Kill Your API - Jonathan Marler (2023)
- zon2nix - Convert the dependencies in build.zig.zon to a Nix expression.
- Types and the Zig Programming Language (2023) (Lobsters)
- Wrap your NIF with Zig (2023)
- Learning Zig (HN)
- Learning Zig basics, multi threading and sockets in 30 minutes (2023)