Conversation

Maybe the biggest unanswered question about Rust is how much the borrow checking rules can help performance by improving compiler alias information. (There is some use of noalias but it's not very aggressive yet.) If they do by a lot, that changes the calculus for using Rust...
21
284
Like, if the borrow check helps runtime performance, then why wouldn't you use Rust over alternatives? It'd be safer *and* faster.
5
98
Replying to
Have a newbie write a linked list in rust to see the problem. I'm a fan, but you really have to understand things before you jump in. Obviously we all WANT devs to know their tools before writing a line of code, but other languages can be a bit more forgiving while folks learn.
2
1
Replying to and
Not more difficult to write a correct linked list implementation with Box<T> (singly-linked) or Rc<T> / Weak<T> than malloc in C. Those types exist in C++ as a higher level, easier to use replacement for malloc/new (std::unique_ptr<T>, std::shared_pointer<T>, std::weak_ptr<T>).
1
Replying to and
I'm not sure what that's meant to demonstrate. If you used the wrong types in C++ you would have the same problems but often with runtime memory corruption which you may not notice and which is hard to debug. In C, you're on your own to manage it properly. How is this harder?
2
Replying to and
With C you can get a 99% correct solution and feel some level of progress as you learn. This isn't really an option with rust. With C you can work through runtime errors, and with rust you can't even compile. Not all programs need to be 100% correct - especially when learning.
1
Rust doesn't enforce that your program is 'correct' and it's not in any way harder to incrementally build a solution. Rust enforces that there isn't memory corruption. A doubly-linked list in Rust and C++ without using raw pointers in either doesn't look that much different.
1
You're taking the claim way too far. It is not easier to use manual memory management and deal with the consequences of memory corruption. It is not easier to need to learn how to use ASan, UBSan, etc. just to get partial detection of the issues as they occur at runtime.
1
Show replies