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.
Conversation
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
1
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
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
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
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
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
I think you're missing my point. With C you have to understand pointers and memory. It's usually easy to write a working program, but very difficult to write one free of errors or security issues. This provides a more gradual learning curve than rust.
1
It's far harder to write a minimal working program in C. It has a far steeper learning curve. It's dramatically less productive. Even for the contrived task of writing something with no practical use that you came up with, what you're saying isn't at all true. Are you trolling?

