placeholder

Safely writing code that isn't thread-safe - Cliffle

One of the nice things about the Rust programming language is that it makes it easier to write correct concurrent (e.g. threaded) programs – to the degree that Rust’s slogan has been, at times, “fearless concurrency.”

Click to view the original at cliffle.com

Hasnain says:

“Rust is the only language where I regularly write non-thread-safe data structures without caveats or fear. In cases where they apply, such data structures can be simpler and often faster than concurrent thread-safe data structures – with the drawback, of course, that you can’t use threads to speed up operations on them.

If you’re coming to Rust from another language that emphasizes concurrency, such as Java or Go or (increasingly) C, keep this in mind:

You don’t necessarily need to make every data structure thread-safe, and

If you get it wrong, you’ll get a compiler error, not a weird runtime bug.”

Posted on 2022-11-24T04:18:17+0000