back

by raphlinus·7y ago·view on hn ↗
C and C++ are sharp tools. They have extensive undefined behavior, but also a formal memory model, so it means something to say, "this code is correct." They also have a culture of people who understand how to deal with undefined behavior, and tools (sanitizers) that make it more feasible.

Rust is safe, unless you go out of your way to be unsafe. It's not just "use a lock," it's "if you try to access shared mutable data without a lock, your program won't compile."

Java has data races but not undefined behavior. It also has a formal memory model.

Swift gives you none of that. Treating threads as a library rather than something with language support is something that might have seemed like a good idea 20 years ago, but now I think we know better.

1 comments
The C model is ‘there is only one core, race conditions don’t exist. Multithreading is undefined.’ How is that better?
That has been changed in C11 to match with C++11, in case you are not aware.