4 ms·
I really want to like Rust, but coming from C++, the language just feels incomplete. There’s a lot you should be able to do safely but the compiler just isn’t t
by brian-armstrong 8y ago
I really want to like Rust, but coming from C++, the language just feels incomplete. There’s a lot you should be able to do safely but the compiler just isn’t there yet to figure it out. I was surprised to find you can’t safely pass ownership of a Box through a channel for example (that is, Box doesn’t implement Send).
I’m also not a fan of the crazy chained functions everywhere, and making ? do an implicit return makes it hard to visually scan code for control flow.
I’m hoping Rust matures into a better language. For now I think C++ is still far more productive and ergonomic, and there are ways of making it safe too.
- Rusky 8y agoBox totally implements Send: https://doc.rust-lang.org/std/boxed/struct.Box.html#synthetic-implementations https://doc.rust-lang.org/std/boxed/struct.Box.html#syntheti... Also I'm not sure how ? obscures control flow to the same level as C++, which propagates exceptions with no syntactic marker at all.
- brian-armstrong 8y agoWell to be fair, I would never advocate using exceptions. Also I’m quite sure Box doesn’t. I’ve seen compiler errors when attempting to pass one via mpsc.
- steveklabnik 8y agoYour parent’s link says Box implements Send only when it’s T is Send, which makes sense.
- brian-armstrong 8y agoI guess? If you’re transferring ownership of something to another thread, that’s perfectly safe. Needing to implement (??) Send for a struct or pod type is cumbersome when it’s something you’d do pretty often.
- Rusky 8y agoGood thing Send is implemented automatically for types based on their contents, then. If you're trying to send a value to another thread, Rust will only stop you if the author of some type somewhere inside it has opted out, and none of its containers ever opted back in (as Box does).
- GolDDranks 8y agoYou don't need to implement Send for POD types – it is automatically implemented. Almost all types implement Send. There are only a few exceptions that I know of: Rc (the non-atomic reference counted pointer) doesn't implement Send because it doesn't support atomically updating the count. Also raw pointers don't implement Send.
- brian-armstrong 8y agoThe fact that we’re even having this conversation, caused by compiler error ambiguity, demonstrates my point about ergonomics nicely :)
- steveklabnik 8y agoPlease file bugs if the errors are confusing!
- brian-armstrong 8y agoEh, they’re probably fine for regular users. They are just nonsensical when you’re starting out.
- steveklabnik 8y agoWe care just as much for people just starting out as we do for regular users; possibly even more!
- huhlig 8y agoIf you want compiler ambiguity in C++ look no further than Templates... C++ is rarely ergonomic to use.
- sacado2 8y agoI preferred the "try!" syntax. The ? is harder to parse visually, harder to find, and makes the language a little more complex (that's one more operator, one more thing to understand, one more thing to parse for tools, etc.)