Is zig lang faster than rust?

Using the size of the hello world binary with default settings isn't a good reason to argue that Rust is not lightweight. I would like to apologize for this conclusion.

The reason why I got involved in this thread was that I felt the discussion here was a bit biased. But that was just a non-well-founded feeling.

I was searching for aspects where Zig could be better than Rust because I'm interested in Rust's strengths as well as weaknesses. And I was simply "surprised" by such a huge binary size in Rust, and I still find it "noteworthy". There may be many reasons why it's like that, and why I shouldn't compare it to C, etc. etc. But in the end, using the operating system I have, using the tools I have, etc., I am not able to get a small hello world binary.[1] I'm looking forward to try Rust in an embedded context, where different rules will apply (and where I have no console to print out anyway, as there is none connected).

I used the binary size as an example where I observed Rust feeling less lightweight to me. In my posts above, I also talked about:

  • dependencies in idiomatic code
  • compiler and language complexity

I have spent literally HOURS in Rust trying to solve very easy problems. Then at other times, I solved problems in a couple of seconds where I would have needed difficult and potentially dangerous constructs in C to achieve the same.

There were also compiler issues I came across when using nightly Rust and unstable features (such as this and that, or undocumented aspects of the type system[2]). Of course, I'm also comparing apples and oranges here, because I never used any unstable C features yet. But I need the unstable features in Rust to be able to use its type system in the way I need. In C I simply do (void *)(…).

I didn't want to say Rust is bad, but Rust still feels not lightweight to me, due to a lot of reasons. Maybe that would change in future.

Edit: To be fair: Rust also doesn't feel overly bloated to me, particularly not in regard to runtime overhead, where it really rocks, considering what it has to offer!

As I said above: My apologies for the implied "conclusion".

Even if this is a Rust forum (and thus naturally biased), I'd appreciate if I can "note" any downsides of whichever language (e.g. in corner cases such as hello world, or when using default settings). Nonetheless, I'd like to thank you (and other posters) for pointing out some of the reasons why the binary size in Rust is bigger (and how to make it smaller when needed). This helps me with understanding Rust's behavior and design choices better.

I tried to make a point about overhead, not about efficiency. Maybe that's the same? Not sure. For sure, I didn't define overhead properly. I just made a comment that I already regretted two messages above.

Edit 2: And let me say once more: overhead isn't necessarily a bad thing.

Yes, I believe my feeling about the huge dependency tree in Rust might be misleading. I still notice that I've never used as many dependencies for simple tasks before I started using Rust. That might be good or bad…


  1. I didn't try hard, though. ↩︎

  2. regarding the reference ↩︎

2 Likes