Zig monthly, September 2021
Unicode, Android, cross-platform GUIs, learning resources & more
Slingworks & The Underburrow game
Underburrow is a speed running platformer game where you gather momentum with well timed button taps
@JonSnowbd shares Slingworks 0.1: a simple and powerful Windows+Linux ‘bring your content’ engine built in Zig, as well as Underburrow: an all encompassing example for how Slingworks development works.
Both are still heavily under development, but it’s already quite cool:
Unicode is complex: even in languages with excellent support for it such as Go (by creators as UTF-8 itself) there is still regular confusion and subtle bugs lurking behind incorrect assumptions about what runes/code-points and grapheme clusters are..
Zig has, thus far, taken a lighter weight stance on Unicode: there are no native unicode types in the language, and the standard library is light weight in terms of Unicode support.
But many in the Zig community, myself included, care about Unicode support immensely - and @jecolon has been working tirelessly on two libraries:
- Ziglyph: Unicode text processing for the Zig Programming Language.
- Zigstr: A UTF-8 string type (which exposes Grapheme clusters instead of code points to avoid foot-guns.)
As well as a series of articles:
@MasterQ32 has created a Zig android template repository - showing off how to create a minimal Android app in Zig.
Also see his earlier 2021 FOSDEM talk: Create an Android Application with Zig - I’ve included a short clip of the demo within for your enjoyment:
Felix also has aspirations to do Zig-on-iOS work, so please consider sponsoring him for some Apple hardware if his work appeals to you!
Test your C code with Zig
IUP (cross platform GUI) for Zig
Rafael Batiati has shared a very interesting article: IUP for Zig:
It’s a cross-platform GUI toolkit developed by PUC-RIO, the same university behind the excellent Lua language.
Robinhood hash tables
Kenta Iwasaki shared their robin hash table implementation:
A robin hood hash table that keeps entries lexicographically sorted. Assumes that keys are 256-bit cryptographic hashes. Able to insert 25.8 million entries per second, query 30.83 million entries per second, and delete 24.21 million entries per second.
Using it as one of the core main-memory data structures for a blockchain I’m writing in Zig called Rheia. Wrote and improved upon the data structure based on Twitter comments and articles made by Per Vognsen and Paul Khuong.
Beats any other sorted data structure I’ve benchmarked so far in terms of insertion/query/deletion throughput by 3-4x order of magnitudes.
Ray tracing in a weekend
Fast LRU cache
Also brought to us by Kenta Iwasaki:
Wrote a really fast LRU cache that is an amalgamation of both a robin hood hash table and a doubly-linked deque.
On my laptop, with a max load factor of 50%, roughly:
- 19.81 million entries can be upserted per second.
- 20.19 million entries can be queried per second.
- 9.97 million entries can be queried and removed per second.
The code is available here w/ unit tests and benchmarks: https://github.com/lithdew/rheia/blob/master/lru.zig
- Crafting an Interpreter in Zig - Andres
- Zig build explained - Felix “xq” Queißner
- Interfaces in Zig - David Vanderson
- Struct of Arrays (SoA) in Zig? Easy & in Userland! - Loris Cro
- How to use hash map contexts to save memory when doing a string table - Andrew Kelley
- Code coverage for Zig - Ryan Liptak
- Resource efficient Thread Pools with Zig - Protty
Now seems like an excellent time to point out two resources for anyone considering learning Zig:
- Ziglings: a series of tiny broken programs. By fixing them, you’ll learn how to read and write Zig code.
New Zig tutorials
- Intro to Zig - Sobeston:
- What’s undefined in Zig? - Loris Cro
- What’s a String Literal in Zig? - Loris Cro
- How to Add Buffering to a Reader / Writer in Zig - Loris Cro
- C/C++/Zig interoperability - Loris Cro
New podcasts & videos
- Zig ⚡ SHOWTIME #29: Don’t Rewrite, Reinvent!
- CoffeeTIME: The ZSF is 1 year old!
- CoffeeTIME: AWS ❤️ Rust - an insightful discussion about the relationship between AWS and Rust
- Launching the TigerBeetle $20,000 consensus challenge, there was a 2.5 hour Zig ⚡ SHOWTIME #28: Viewstamped Replication Made Famous.
- Viewstamped Replication Made Famous - Joran Greef
- Revisiting Viewstamped Replication with Brian Oki and James Cowling
- Coderlyfe has been steadily producing a series of Zig video tutorials if that’s your cup of mocha:
Handmade Seattle has several attendees from the Zig community, as well as talks and demos for Zig November 11-12, 2021.
P.S. In case you missed it, Zig 0.8.1 has been released!
If you’re one of the 150+ subscribers or 3.5k+ viewers, thanks for reading!
Please consider supporting my work