4 ms·
Sounds more or less (and pardon me if I'm oversimplifying) Java's "synchronized" keyword that most people stay away from just because it slows the code down so
by commandlinefan 4y ago
Sounds more or less (and pardon me if I'm oversimplifying) Java's "synchronized" keyword that most people stay away from just because it slows the code down so much you don't get the benefit of parallelization.
- duped 4y agoThey couldn't be more different. Java's synchronized keyword changes how code is interpreted to use expensive locking and data fences in order to prevent logical race conditions. Rust's semantics do not alter the compiled code or insert any locking behavior. They prevent you from writing incorrect code to begin with. In other words, Rust doesn't do anything magical to deal with data races at run time. It prevents you from expressing programs that have data races in the first place. It's a compile time analysis, not a run time behavior.
- commandlinefan 4y agoInteresting, thanks for clarifying.