News for hackers. Stuff that matters.
Re:Crossbeam – Tools for concurrent programming in Rust by jpgvm on Sunday April 17, 2022 @05:17AM (#31059586)
Is it possible for Rust to implement an uncolored implementation like Project Loom for Java or Golang goroutines?
Re:Crossbeam – Tools for concurrent programming in Rust by aliceryhl on Sunday April 17, 2022 @07:19AM (#31060067)
The way those languages implement something that is uncolored is by making everything async. Rust has some other use-cases where that's not acceptable.
Re:Crossbeam – Tools for concurrent programming in Rust by jpgvm on Sunday April 17, 2022 @08:26AM (#31060379)
Well that isn't entirely true. Java is doing it in a similar way to Go in that every call to I/O or other function that would block can suspend the current virtual thread. But if it's called in a standard blocking thread then it blocks as expected (in Java w/Loom that is, ofc every goroutine is a green thread). This is of course a ton easier in Java and Go because of the managed memory model.

However I would be interested in hearing what the specific Rust features (or lack thereof) that prevent this being possible. If it's possible to swap the async runtime out it seems like it should also be possible to add enough runtime to a Rust program to allow the equivalent of virtual threads as long as stuff uses stdlib sockets, file I/O etc.

Re:Crossbeam – Tools for concurrent programming in Rust by ______-_-______ on Sunday April 17, 2022 @10:00AM (#31060864)
It's not due to the memory model; it's due to the lack of a runtime. In Go/Java, virtual threads are provided by a runtime. Rust tries to stay close to the metal, and so has no runtime. It does not have virtual threads that could be suspended.

Rust used to have virtual threads pre-1.0, but they were removed since the overhead was deemed unacceptable.

Re:Crossbeam – Tools for concurrent programming in Rust by accountofme on Sunday April 17, 2022 @05:20AM (#31059594)
Great! I would love that. However, having read the comments of the rust async working group, they think that async is the best thing since sliced bread ... They have no intention of changing IMO. Sigh. Hopefully one day we will get inclusive features rather than exclusive... Cheers
Re:Crossbeam – Tools for concurrent programming in Rust by rapsey on Sunday April 17, 2022 @05:48AM (#31059703)
You are welcome to propose a better method
Re:Crossbeam – Tools for concurrent programming in Rust by accountofme on Sunday April 17, 2022 @07:00PM (#31065363)
No I think I should put my money where by mouth is: I will take another route: asyncless rust should be simple enough to remove that part and make async/await compiler errors. Add this as a new target to rustup and we are good.