News for hackers. Stuff that matters.
Re:Java is not a safe language by duped on Monday June 13, 2022 @10:10AM (#31725825)
A data race occurs when two or more parallel processes access the same data and at least one of them is mutating it.

Safe Rust forbids this through ownership and move semantics along with lifetime analysis. You may create any number of immutable aliases to data, or exactly one mutable alias. You cannot mix the two.

Unsafe allows you to (kind of) sidestep the automatic checking, but its your responsibility to uphold those conditions.

Re:Java is not a safe language by commandlinefan on Monday June 13, 2022 @01:00PM (#31728243)
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.
Re:Java is not a safe language by duped on Monday June 13, 2022 @01:43PM (#31728830)
They 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.

Re:Java is not a safe language by commandlinefan on Monday June 13, 2022 @02:19PM (#31729299)
Interesting, thanks for clarifying.