So I recently had to compromise the ergonomics of my library (GitHub - audulus/rui: Experimental Rust UI library) because Rust doesn't allow arbitrary code to be executed on assignment.
That is, an expression of the form x=y always denotes a bitwise copy and no allocation happens. The
Copy trait is "Types whose values can be duplicated simply by copying bits."
Rust devotees seem to love this, so you don't need to tell me how much you do. I chalk it up to survivorship bias.
Anyway, suppose you wanted to make a NxM (dynamic) matrix type (like Eigen, say) and you want it to have good ergonomics, so
x = y not
x = y.clone(). Can't do it.
"but it's just a call to
clone. No big deal!"
Ok, fine, well what about this case:
f(move || g(a, b)); f(move || g(a, b));
If a and b aren't
Copy I've gotta clone them:
let x = a.clone(); let y = b.clone(); f(move || g(a,b)); f(move || g(x,y));
In my UI library case there were more lines of cloning and things got a bit ugly. It took away from the declarative style.
Annoying. What I ended up doing was making those types
Copy, which caused other ergonomics issues, but I decided the tradeoff was worth it.
I was just talking with a programmer I respect greatly, who used rust for a project but decided because of this behavior it felt "too low level" and went back to C++ (for new projects!). He wants to program in a very value-oriented FP style. I've also spoken with a rather prominent rust programmer who called it an "ergonomics paper cut."
Now, I understand the point of standard library types not copying implicitly. They should be designed with performance in mind. But there are cases where you'd like to have ergonomics over performance. So I think it would be great if the user had the freedom to implement
Copy as they want.
People of course say they like that this enforces a style on people so other people's code obeys their preferred rules. If you believe that, you may be a bit of an authoritarian. If an organization wants to dictate "Copy must be bitwise", that's fine. But for a language to say it feels more like a religious edict.
Anyway I'd love to see rust replace c++, so we all can have an easier time programming (I've done c++ professionally for two decades, sadly). Rust's memory safety, thread safety, powerful type system, and great package management should be convincing enough. Taking away this barrier would be another step IMO.