this post was submitted on 03 Oct 2024
47 points (88.5% liked)

Programming

17123 readers
123 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 [email protected]



founded 1 year ago
MODERATORS
 

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.

@[email protected]

you are viewing a single comment's thread
view the rest of the comments
[–] Giooschi 1 points 1 day ago

So, basically, you are managing Arenas of variables instead of managing the lifetime of every single, individual variable, one at a time.

How does that handle stuff like vector reallocation? Does it keep both the old and the new vector allocation around until the arena scope ends? That seems very wasteful and I doubt it is how the release allocator handles it.

What's cool with that is you can manage the memory differently for each allocation by using a different type of allocator, which give you more control if desired.

This creates the risk of using the wrong allocator for deallocating.

Do you want to talk about the covariant, invariant, contravariant and invariant in Rust? Because that's a hell of a topic to manage the lifetime in Rust. Don't forget, you have to manage that for /every/single/ variables, one a time. Good luck keeping you sanity in a large project.

Variance is the property of a type, not a variable. You don't have to "manage" variance, you just have to respect it. And lifetime variance as a concept is something that exists in C/C++/Zig too and has to be respected, but the compiler generally does nothing to tell you about it. If someone doesn't understand that then I fear for what they will write in a language that doesn't make it clear to them.

Here is a good talk about what I try to tell you: Individual Element Thinking

I'm not going to spend my time watching a video just to reply to some random guy online, but I will try to give it a go later on if I have time in case it is actually interesting.

Security goes beyond "smart pointers". Just think of the fact Rust doesn't have shared libraries.

Shared libraries are in fact a massive source of unsafety since there's almost no way to guarantee compatibility between the two sides.

And being able to track dependencies with a proper package manager like cargo already does a pretty good job at tracking what you need to update.

Because Rust also has that fyi

Most of which are actually denial-of-service, unmaintained crates, or unsoundness in some crates.

Unsoundness "vulnerabilities" which would just be considered "documentation issues" in languagues that don't take memory safety as seriously, or maybe they would never be found because you have to go out of your way to actually hit them.