I am U-Zyn Chua. I build, research and write about technology, AI and the open web.
Posted on :: Tags: ,

My journey started casually enough—working on Tixie, I was looking into simpler ways to deploy Rust-based Lambda functions when I came across Cargo Lambda. What got my attention was that it is so easy to cross-compile with it, mainly due to Zig's powerful build system. Even though it was built for Rust developers, it utilizes Zig for cross-compilation, allowing me to compile ARM binaries that worked on AWS Graviton on my Apple Silicon Mac.

That was the start of a series of rabbit holes that consumed me for more than a week.

Rabbit hole #1: Zig

I have heard about Zig prior but had not looked into it deeply. This new brief encounter quickly turned into a deeper dive, pulling me into an engaging exploration. It also seems like Zig community consists of quite a significant "Rust refugees".

Rust is memory-safe, extremely, but it can be rather annoying and unforgiving for developers on many of its designs. Personally for me, what annoyed me the most is its error handling.

Notable projects such as Bun—a JavaScript runtime gaining popularity—are turning to Zig for its simplicity, clarity, and efficient build system. I spent more than a week learning and diving deep into Zig – I like it so far for its C-like syntax, being a low-level language like Rust, and more straightforward language design choices compared to Rust.

Rabbit hole #2: Jetzig

I am working on a project which I have started on Rust for a bit.

As I got deeper into Zig, I stumbled upon Jetzig, a Model-View-Controller (MVC) web framework built on and for Zig. What particularly intrigued me about Jetzig was that it seems to be very suitable for HTMX and Hypermedia Systems, a development stack and philosophy that I gravitate towards lately for my goals in simplifying build process.

I spent the next few days learning and experimenting with Zig and Jetzig.

Rabbit hole #3: Zmpl

Jetzig's built-in template language is Zmpl. However, with it being a rather new language, there was one problem — working without syntax highlighting felt uncomfortable.

No Zmpl syntax highlighting extensions was available yet on the VS Code extension marketplace. Zmpl's page did mention one. Unfortunately, I could not get the extension installed. Also, looking into it, it seemed like it lacked some comprehensive definitions. I thought about fixing it by creating one; how hard could it be?

Rabble hole #4: tmLanguage and VS Code extension

First thing to learn: tmLanguage, a syntax grammar definition structure originally created for TextMate. It is still widely used by most popular code editors today, surviving TextMate, such as Visual Studio Code, Cursor, Sublime Text, and Atom. Unfortunately, resources for tmLanguage were strangely limited. This blog by Matt Neuburg was helpful in explaining the concept. Interestingly, it was written more than 11 years ago in February 2014.

That took a few days of intense development, testing, and refining and finally created something functional. While it wasn't perfect especially for multi-level nested mode switches, it was a significant improvement over existing solutions and met my needs for now.

I released my Zmpl syntax highlighting extension on the VS Code Marketplace and open sourced it.

Preview in Monokai theme:

Syntax highlighting in Monokai theme

What started as a small personal inconvenience turned into multiple rabbit holes that consumed me for more than a week, but emerging with an appreciation for Zig, and learned about tmLanguage and the VS Code ecosystem.

Now, time to get back on my original project.

Read more