this post was submitted on 05 Oct 2024
105 points (94.9% liked)

Programming

17195 readers
456 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
you are viewing a single comment's thread
view the rest of the comments
[–] Saizaku@lemmy.dbzer0.com 4 points 1 week ago (2 children)

Arguably modern c++ ( aka if you don't use raw pointers), fits all categories.

[–] Ephera@lemmy.ml 2 points 1 week ago (1 children)

I don't know much about C++, but how would that do memory safety in a multi-threaded context? In Rust, that's one of the things resolved by ownership/borrowing...

Or are you saying arguably, as in you could argue the definition of the categories to be less strict, allowing C++ as well as Java/C#/etc. to match it?

[–] Saizaku@lemmy.dbzer0.com 5 points 1 week ago

Because you would be using std::shared_ptr<> rather than a raw pointer, which will automatically deallocate the memory when a shared point leaves the scope in the last place that it's used in. Along with std::atmoic<shared_ptr> implements static functions that can let you acquire locks and behave like having a mutex.

Now this isn't enforced at the compiler level, mostly due to backwards compatibility reasons, but if you're writing modern c++ properly you wouldn't run into memory safety issues. If you consider that stretching the definition then I guess I am.

Granted rust does a much better job of enforcing these things as it's unburdened by decades of history and backwards compatibility.

[–] arendjr@programming.dev 1 points 1 week ago

Modern C++ does use references, which can also reference memory that is no longer available. Avoiding raw pointers isn’t enough to be memory safe.