Get the latest tech news

Zig's Lovely Syntax


It's a bit of a silly post, because syntax is the least interesting detail about the language, but, still, I can't stop thinking how Zig gets this detail just right for the class of curly-braced languages, and, well, now you'll have to think about that too.

Zig doesn’t have inheritance, mixins, argument-dependent lookup, extension functions, implicit or traits, so, if you see x.foo(), that foo is guaranteed to be a boring method declared on x type. Usually, the gluing is achieved by making the standard library privileged and allowing it to define intrinsic functions without bodies, or by adding ad-hoc operators directly to the language (like Rust’s as). Even with a small feature-set fixed, there’s still a lot of work to pick a good concrete syntax: unambiguous to parse, useful to grep, easy to read and not to painful to write.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of zig

zig

Photo of Lovely Syntax

Lovely Syntax

Related news:

News photo

Resizable structs in Zig

News photo

Zig's New Writer

News photo

Zig's new I/O: function coloring is inevitable?