3 ms·
> Again, I use Rust and Go similarly in this post because Go is my frame of reference. I thought they were the same on this front, though. No? No. Rust used to
by jabl 9y ago
> Again, I use Rust and Go similarly in this post because Go is my frame of reference. I thought they were the same on this front, though. No?
No. Rust used to have a green threads runtime like Go (and Erlang/BEAM, Haskell, etc.) but that was removed before the 1.0 release. So today, a thread in Rust is a heavyweight OS thread, like in C/Java and most mainstream languages.
- tytytytytytytyt 9y agoThe intro Rust book says you can easily find crates for green threads of you really want them. Is this not the case?
- tiuPapa 9y agoI am not entirely sure, it appears like due to the present status of std in rust, any green threads lib is prone to Undefined Behaviour whenever something uses Thread Local Storage.
- notheguyouthink 9y agoYea, I'm aware - but you can spin off a async execution and then send data back over channels (I forget what Rust calls), as well as wrap that whole thing up in a function with a return value so that the caller has no idea of the threaded execution taking place. Right? Sure the implementation of the threading differs greatly, but I was mainly referring to that I can spawn async behavior, and use synchronous blocking methods to get data back from that async behavior - AND encapsulate it. All of these are very different than, say, what JavaScript goes through anytime async is involved.
- steveklabnik 9y agoRust also has channels.