this post was submitted on 15 Jul 2023
546 points (98.1% liked)
Programmer Humor
19552 readers
1313 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
C++ does have the problem that references are not objects, which introduces many subtle issues. For example, you cannot use a type like
std::vector<int&>
, so that templated code will often have to invokestd::remove_reference<T>
and so on. Rust opts for a more consistent data model, but then introduces auto-deref (and the Deref trait) to get about the same usability C++ has with references andoperator->
. Note that C++ will implicitly chainoperator->
calls until a plain pointer is reached, whereas Rust will stop dereferencing once a type with a matching method/field is found. Having deep knowledge of both languages, I'm not convinced that C++ features "straightforward consistency" here…