Hacker News new | ask | show | jobs
by umanwizard 263 days ago
> That, and all languages more or less converged to the same functionality with different syntax/naming conventions.

That is not even close to true.

In Go or C or C++ I have to respect comments that say “make sure to hold mutex foo before calling this function!” In Rust I don’t, the type system enforces it at compile time. That alone is a huge difference and there are many differences like that.

1 comments

You can encode mutex holding into the type system in C++ in a very similar way as Rust. E.g., APIs can take folly::Synchronized<T>::RLockedPtr: https://github.com/facebook/folly/blob/76f81836a2ccb6cd3bc7d...
Fair enough — you can do that, which is nice, but in Rust it happens automatically. A program that attempts to concurrently mutate the same object without taking a mutex will always fail to compile (unless you hack around this restriction with unsafe) whereas in C++ you have to intentionally build the API that way.