Jump in the discussion.

No email address required.

Someone inform me on Rust

I heard that the whole safety thing they have a girldick boner for is basically the same as if C++ enforced a usage pattern of C++11 smart pointers (not neurodivergentally the same, basically the same)

My reading of Wikipedia is not inconsistent with this, is this how it is?

Jump in the discussion.

No email address required.

There are tradeoffs in terms of performance too; c++ has a better story with stack call memory usage, and it tends to use less memcpy's under the hood currently. On the other hand, rust allows functions like this (pretend it's not small enough to be inlined) to be optimised by the compiler where languages without a borrow checker simply cannot do so:

void func(int &x, int &y) {
    x += y;
    x += y;
}

I strongly, strongly suspect that for general development performance it's incredibly unlikely that in the future Rust won't be faster than C/C++ unless new keywords/lifetimes are added into the respective specs. Given the development velocity of C++20, this seems unlikely at best.

Jump in the discussion.

No email address required.

No, there are real practical differences. C++ smart pointers aren't good enough, and many items in c++ that are introduced for memory safety reasons turn out to be horrible, for instance string views.

Tbh the benefit of rust isn't it's memory safety, it's just how much better it is to develop with. There's no comparison in c++ with cargo, and the borrow checker is extremely handy after the initial hurdle.

Jump in the discussion.

No email address required.

Yeah I'm not codecel enough to explain that but my understanding is the tooling around Rust and Rust getting things right the first time is a big boon.

Jump in the discussion.

No email address required.

I'm not actually a codecel but Rust makes you write code and WILL NOT COMPILE if you're not memory safe.

If you're codecel enough to read up on C++11 I assume you would understand what that entails better than me.

EDIT: I should also point out the language made tooling a number one priority like Go. Which is very important for modern languages.

Jump in the discussion.

No email address required.

>If you're codecel enough to read up on C++11 I assume you would understand what that entails better than me.

For example in a memory-unsafe language like C, if you have a null pointer and you try to dereference it, the CPU will fault and the OS will send SIGSEGV to your program. If your program doesn't have a buffer saved to longjmp() back to, that's it, you're crashing, even if you write a SIGSEGV handler it can't return.

In a memory-safe language like Java, if you have a null reference and try to dereference it, the Java runtime will detect this and cause your program to throw a NullPointerException. This is one way it's safer, the CPU and OS don't know you fucked up. But if you don't have code to catch NullPointerException, that's it, you're crashing. But writing the handler is easy, you just say catch (NullPointerException e) {} and your NPE errors messages go away.

Jump in the discussion.

No email address required.

:marseyreading#:

Thanks for the tips, yeah my understanding is Rust would catch all that at compile time.

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.