Zig NEWS

loading...
Zig monthly

Zig monthly, September 2021: Unicode, Android, cross-platform GUIs, learning resources & more

Stephen Gutekanst
・7 min read

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 (click to expand):

Check it out: Slingworks | Underburrow

Unicode

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:

@andrewrk and @jecolon are also working together to ensure Zig's std.unicode library is a reasonable API in general before Zig 1.0.

Android support

@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

@Pixeli on Twitter has shared an extremely cool topic: how to easily test your existing C code using 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.

https://github.com/lithdew/rheia/blob/master/hash_map.zig

Ray tracing in a weekend

@Jack-Ji has implemented the famous ray-tracing-in-a-weekend in Zig:

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

Exceptional articles

Learning Zig

Now seems like an excellent time to point out two resources for anyone considering learning Zig:

New Zig tutorials

Since last month's beginner tutorials, https://zig.news has blown up with awesome tutorials all around:

New podcasts & videos

Upcoming events

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

Discussion (0)