NewsCrawler.org

Four Months of Zig: a returning developer's impressions

A developer who returned to Zig after a few years away sums up about four months with the language, with comparisons to Rust, their previous go-to language. Their first project is snurl, a library for the smallnet[1] protocols such as Gemini, Finger, Gopher and Spartan, meant as a curl-style client with similar testing and fuzzing[2] requirements on a smaller scale, written roughly along TigerStyle lines. Zig's built-in fuzzer turned out not to work because the feature is unfinished, even though it is demonstrated in the main.zig file generated by zig init.

Two more projects remain unpublished so far: a TUI typer racer and an n-body simulator with stellar evolution built on raylib. At Zig Day Seattle, announced on Lobsters on August 20th, the author worked on snurl with Evin Yulo, who began integrating Zig's standard library TLS implementation as an alternative backend, and briefly talked with Zig creator Andrew Kelley; the event moved from the Bellevue library to the Bothell library after signups overwhelmed capacity. Among the things they like, anyzig let them run both zig master and 0.16.0 for different projects, though it fails outside directories with a build.zig.zon, breaking autoformatting for their one-off Zig scripts.

Explicit allocator[3] and IO parameters make it clear which functions allocate memory or reach the operating system, which they prefer over Odin's implicit context and Rust's hidden allocations that panic when memory is exhausted. The IO parameter also eases testing, since a testing IO instance can supply inputs or force write failures, and porting Zig to new operating systems is mostly porting IO. They further praise comptime[4] and the build system, which companies like Uber have adopted for software in other languages and which integrates external tools where Cargo complains. A culture of avoiding dependencies leaves their Zig programs with one or two direct dependencies and zero indirect ones, and the laziest way to handle errors — try plus a ! return type — happens to be the correct one, unlike Rust, where panics added while prototyping tend to stay in the code.

Read the original gracefulliberty.comDiscussion

Discussion

The only commenter reports that curl could not resolve the site's hostname and asks whether the 'HN effect' is to blame.

Sources

Published: First seen: Читать по-русски

Open as a page