DEV Community

Cover image for Rust vs. Zig: A Head-to-Head Comparison of Two Modern Systems Programming Languages

Rust vs. Zig: A Head-to-Head Comparison of Two Modern Systems Programming Languages

Kinanee Samson on September 25, 2023

Lots of new programming languages are trying to replace the C programming language, most of which have been tagged the C killer. Most notable in th...
Collapse
 
taikedz profile image
Tai Kedzierski

A pleasant and succinct overview. Both languages look promising at this stage.

Last conclusions however are to be taken lightly - I have a preference for Rust over Zig (personal reasons which aren't worth highlighting here), and a Linux advocate, but I would say it's a little misleading to claim

one of the biggest apps to be built with Rust is the Linux Kernel

implying that a major part of the kernel is written in rust - which is not true. The Linux kernel project has started accepting modules being written in rust to integrate with the kernel, and has thus added tooling to do so during kernel build. This is good 😁 but not quite "Linux is built in rust" 😅

It is worth noting that Microsoft has added Rust to its codebase too


Conversely, Zig's Bun project is indeed gaining good visibility 🎉

Collapse
 
kalashin1 profile image
Kinanee Samson

A huge milestone for the Rust community.

Collapse
 
tythos profile image
Brian Kirkpatrick

Ultimately I find that the Zig compiler is much less of an asshole than Rust. Between that and the Foundation drama (not to mention the ease of cross-integration with legacy C) I think Zig is going to be the focus of my attention for 2024. Now if only they can help the documentation and secondary tooling (like examples and regex libraries) keep up with the compiler releases!

Collapse
 
kalashin1 profile image
Kinanee Samson

I really hope that they do

Collapse
 
mslapek profile image
Michał Słapek

Nice article, my favorite part was "Real World Application". 😀

I think one of the major differences is aliasing: by default, Rust forbids mutable aliasing.

Zig (like C, C++, Python, etc...) allows mutable aliasing by default (there is a dedicated keyword in C/C++ to inform about lack of the mutable aliasing, en.cppreference.com/w/c/language/r...).

Collapse
 
kalashin1 profile image
Kinanee Samson

wow, I had no idea, thanks for your contribution.

Collapse
 
sergeyshandar profile image
Sergey Shandar

I would also mention meta-programming, by comparing amazing Zig compile-time reflection vs not so amazing Rust macros.