News for hackers. Stuff that matters.
Re:My Go Resolutions for 2017 by dbaupp on Wednesday January 18, 2017 @04:05PM (#13430270)
Rust's "sharing xor mutability" guarantee eliminates data races by (usually statically but also dynamically) ensuring that a memory location won't be mutated when multiple places/threads can access it. Of course, the machinery required for this in Rust is relatively complicated (e.g. as a side-effect, it allows one to also forgo a GC without losing safety).
Re:My Go Resolutions for 2017 by brightball on Wednesday January 18, 2017 @04:07PM (#13430288)
How is that different from a mutex lock?
Re:My Go Resolutions for 2017 by dbaupp on Wednesday January 18, 2017 @04:15PM (#13430351)
Rust lets you be precise about placing the locks exactly where they are needed, with compile time errors if a lock isn't locked when accessing data, or a lock is missing. Fixing data races with locks for arbitrary code, without more static guarantees in the language, essentially means locks have to be held for most memory accesses: it's hard/impossible to tell if that location will be accessed concurrently. (This is why CPython has a GIL: it's easier to only let one piece of code execute at a time than to handle data races in arbitrary code.)

https://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.h... is interesting reading.

Re:My Go Resolutions for 2017 by kazagistar on Thursday January 19, 2017 @01:00AM (#13433434)
For example, in Rust, it will stop you from accessing the value protected by a Mutex after the lock is freed, and do so at compile time, even through function calls, pointers hidden in data structures, etc.

Another example: I can take a value and mutate it locally, then pass it immutably to a number of threads which use it to compute some results, and once they are all complete, I can mutate the data structure again. If I try to write mutation code before all the threads are re-joined, the compiler will tell me that I can't mutate while there are outstanding immutable borrows. At compile time, at no runtime overhead or locking.

Re:My Go Resolutions for 2017 by sinhpham on Wednesday January 18, 2017 @04:13PM (#13430338)
It's being done at compile time.