# Zig Programming Language

- Page: https://shared.btbytes.com/p/ziglang
- Date: 2020-04-13
- Tags: programming-language, zig

[The Zig Programming Language](http://ziglang.org/) is an open-source programming language designed for robustness, optimality, and clarity.

## Introduction

- [Introduction to the Zig Programming Language - Andrew Kelley](http://andrewkelley.me/post/intro-to-zig.html)
- [zig in 30 minutes](https://gist.github.com/ityonemo/769532c2017ed9143f3571e5ac104e50); [HN](https://news.ycombinator.com/item?id=25618302); Jan 2021.
- [Learning Zig](https://www.openmymind.net/learning_zig/)  by [Karl Seguin](https://github.com/karlseguin).
- [Zig's Lovely Syntax](https://matklad.github.io/2025/08/09/zigs-lovely-syntax.html); Aug 2025 by `matklad`.

## Code

- [andrewrk/tetris: A simple tetris clone written in zig programming language.](https://github.com/andrewrk/tetris)
- [Hejsil/pokemon-randomizer: A Pokémon Rom randomizer tool written in Zig](https://github.com/Hejsil/pokemon-randomizer)
- [dbandstra / oxid · GitLab](https://gitlab.com/dbandstra/oxid/)

## Learning

- [An Introduction to Zig](https://pedropark99.github.io/zig-book/), a project-based book.


## Articles

- [Porting Zig to NetBSD - a fun, speedy port](http://coypu.sdf.org/porting-zig.html)
- [Iterative Replacement of C with Zig](http://tiehuis.github.io/iterative-replacement-of-c-with-zig)
- [How Zig Do?](https://blog.jfo.click/how-zig-do/)
- [Zig Learn](https://ziglearn.org/)
- [Zig – Mitchell Hashimoto](https://mitchellh.com/zig) and [writing](https://mitchellh.com/writing)
- [Zig And Rust](https://matklad.github.io/2023/03/26/zig-and-rust.html) by Alex Kladov/`matklad`
- [Zig Quirks](https://www.openmymind.net/Zig-Quirks/)
-  [Ziggifying Kilo](https://bingcicle.github.io/posts/ziggifying-kilo.html); Apr 2023.
- [When Zig is safer and faster than Rust](https://zackoverflow.dev/writing/unsafe-rust-vs-zig); Mar 2023.
- [Problems of C, and how Zig addresses them](https://avestura.dev/blog/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](https://medium.com/@penberg/why-i-am-not-yet-ready-to-switch-to-zig-from-rust-3660e02f0060)
- [Why Zig Clicks](https://mattjhall.co.uk/posts/why-zig-clicks.html); Mar 2021

	- A small core
		- tagged unions
		- optionals
		- automatic deserialization to structs
		- type checked string formatting
	- Local Reasoning
	- Generics
	- C interop
	- RAII

## Project Management

- [Mastering project management in Zig](https://blog.orhun.dev/zig-bits-03/) from [orhun's blog](https://blog.orhun.dev).


## FFI

- [(2) Exporting C APIs from Zig, D, and Nim - YouTube](https://www.youtube.com/watch?v=4o_tmccinds)

## Twitter

* Andrew K: [Friendly challenge for Go programmers:](https://mobile.x.com/andy_kelley/status/1189736292151627776)

> 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` and `std.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](https://irclog.whitequark.org/zig/2018-09-25)]


```
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
```

## Software written in Zig

- [buzz-language/buzz: 👨‍🚀 buzz, A small/lightweight typed scripting language (in development)](https://github.com/buzz-language/buzz)
-  [DNNs from Scratch in Zig](https://monadmonkey.com/dnns-from-scratch-in-zig)
