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
Replying to and
That's not how memory corruption works in C at all and it doesn't simply manifest as a 'runtime error'. You seem to be talking about a dynamically typed language like Python, not C. It's in no way easier to do this task at a much lower level where you get incomprehensible bugs.
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
Someone learning C as their first language is going to have a dramatically harder time than someone learning Rust. That includes working their way up to this task as they learn the language and then going through it. If you know C obviously you're quicker in C. Not the point.
1
Show replies