Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If it compiles, it is data-race free

False:

    (0..10_000).into_par_iter().for_each(|_| {
        counter.store(counter.load(Ordering::SeqCst) + 1, Ordering::SeqCst);
    });
    println!("counter {}", counter.load(Ordering::SeqCst));
Rustaceans who think the borrow checker is some kind of miracle cure against every type of bug there is gets under my skin.


A race condition is not the same as a data race, and nondeterminism is not the same as undefined behavior.


Fine, but in practice a data race is just a special case of a race condition so my point still stands. Most multi-threaded code with races is more like my example than the author's and Rust will not magically prevent such race conditions.


Indeed, I like your example, usually I go after external resources being accessed from same threads, database accesses without proper transaction management, or OS IPC, where the Rust threads don't have any visibility about what the other processes are doing.


As a Rust user, the RESF-type no-effort comments are very frustrating. Hopefully it dies down in a few years.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: