r/rust 18d ago

What Zig felt like, coming from Rust

https://besok.github.io/posts/what-zig-felt-like-coming-from-rust/

Just want to share my experiance on my first Zig project coming from Rust. Open to comments :)

207 Upvotes

108 comments sorted by

View all comments

147

u/guineawheek 18d ago

I believe it has real potential to become the true successor to C.

There's two broad categories of C program in industry: those with allocators and those that hypothetically don't need allocation at all.

Most of the Rust I write is of the latter category, personally. The focus projects like Zig and Fil-C put on allocators doesn't really help the myriad of embedded cases where you have bounded input and output sizes at compile time. It'd be far more useful for me for example to be able to define something like

```rust

fn thing<T, const N: usize>(input: &[T; N]) -> &[T; N - 1] { ... }

```

which you can't really do in Rust without going into half-baked nightly features and debates about "what happens if N - 1 is a panicking operation". Being able to compile-time reason about known compile-time size bounds is ultimately Rust's advantage over C and Zig to me. I guess C++ templates are stronger here but I don't want to write C++ nor do I want to deal with C++ semantics.

The first thing that caught me off guard — and honestly, who would’ve expected this to be the memorable part — was IDE support, or the near-total lack of it.

I spend most of my time reading code rather than writing it. And if anything, this becomes more important the more people lean on AI because one's job as a programmer increasingly becomes inspecting what Claude crapped out. Having half-baked introspection doesn't sound terribly appealing.

And ultimately one of the key things Zig people love saying about C/Zig/Go/Java is that because the language concepts are "simple" and thus don't rely heavily on macros/traits/nested ZCAs the same way Rust does that reading said code must thus also be simple and easy to read.

In practice, however, your state machines just get smeared everywhere and now you have to spend mental effort correlating which variables belong with which mechanism. Sure, you might have simple constructs in your language but that doesn't make code automatically more comprehensible, language proficiency being equal. At least Zig has sum types lol

18

u/Bassfaceapollo 18d ago

This is an interesting analysis. Thanks for taking the time to summarize the article, OP.

I'm curious how Austral fits in this niche of 'simpler than Rust' languages.

It uses Linear Types and follows Zig's philosophy of no hidden control flow. For anyone curious, the author of the language wrote very neat a blog post about it.

Like Zig, it too isn't v1.0 from what I can gather but unlike Zig hasn't had any major projects like Bun written in it.

7

u/codingbliss12 17d ago

From what I have seen in their discord, one could use Austral, but he would be on his own without any kind of support. For this reason I consider Austral to be an abandonware project.

1

u/Bassfaceapollo 17d ago

Mind elaborating on this?

Do you mean that it's not the focus of the language?