A Rust veteran ports a JSONPath library to Zig — and rethinks his habits
A developer with seven years of Rust experience rebuilt his JSONPath query library (RFC 9535) in Zig to get an honest feel for the language as a possible C successor. The most jarring difference wasn’t the language itself but the tooling: Zig offers little beyond syntax highlighting and basic autocomplete, which pushed him off a full JetBrains IDE and onto a command-line workflow built around build.zig and a helix/alacritty/zellij setup. What began as a limitation became a selling point, reminding him how capable bare CLI tooling can be.
Two structural lessons stood out. Zig quietly discourages deep folder hierarchies, nudging toward flat layouts where related code lives in one larger file that you navigate by section; his Zig port collapsed to five files versus Rust’s nested parser and query modules, and he never needed a real directory tree. Testing was the reverse — Zig’s inline tests looked similar to Rust’s on paper but felt more verbose, and much of the friction traced back to Zig’s manual memory management rather than the test framework.
The biggest adjustment was paradigm. His Rust code leaned hard on functional idioms — monadic error handling, immutable transformations, iterator combinators, closures, and sum types — most of which don’t survive the move to Zig. Where Rust favors immutability and combinators, Zig pushed him toward in-place mutation and plain imperative patterns, swapping Rust’s trait-based dispatch for Zig’s compile-time duck typing. Sum types were the rare concept that carried over cleanly.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.