39

Zig vs Rust. Which one is going to be future?

I think about pros and cons and what to choose for the second (modern) language in addition to C.

@programming@programming.dev

you are viewing a single comment's thread
view the rest of the comments
[-] PushButton@lemmy.world -1 points 3 days ago
  • Zig uses allocators, which will inform you if you are leaking memory.
  • Zig comes with defer/errdefer to simplify the resource cleanup (and for ergonomics).
  • Zig comes with Optionals to manage nulls.
  • Zig comes with slices (ptr + size) to manage all the bound-checking.
  • Zig automatically check for overflow/underflow arithmetic.
  • Zig will check for pointer alignments when casting between pointer types.

=> Zig is designed to make you do it right easily, and very hard to do it wrong.

In other words, Zig will let you be, but warn you when you are doing something wrong, where Rust is like Karen who is always screaming at you for every word you are typing.

To summarize, you really need to /want/ to fuck up to fail your memory management... If after all that you still can't manage your memory, it might be better for you to look for another carer.

Something is sure thou, Zig is very safe - just as it's safe to cut my veggies with a knife. I might cut a finger and bleed a little bit, but I will not use plastic knife "because it's safer".

Moreover; You are talking like if Rust is safe, all the time, which is not true in reality:

52.5% of the popular crates have unsafe code. Therefore, in an average real-world Rust project, you can expect a significant number of the dependent crates to have unsafe code -- Source

Basically, you're comparing a hypothetical world where Rust is always safe to a superficial glance at Zig's capabilities to claim a "winner" here.

And for the String library... Are you fucking serious? Do you want to compare the Zig's Std library versus the famously tiny Rust Std library? Really?

this post was submitted on 03 Oct 2024
39 points (86.8% liked)

Programming

17135 readers
151 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS