News for hackers. Stuff that matters.
Re:Chris Lattner left Swift core team by ithkuil on Tuesday February 22, 2022 @02:37AM (#30425040)
Sure, you can technically call other rust code from async rust and thus you can also technically call C code via FFI, but if that code blocks you have a problem. There are ways around it but they are hard to use and create the pressure towards just rewriting the whole thing in rust.

I could be wrong though. The reason I like to discuss these things here is the opportunity to be proven wrong by someone who knows more and offers a counter-example

Re:Chris Lattner left Swift core team by maxthegeek1 on Wednesday February 23, 2022 @11:58AM (#30443212)
If you need to call blocking code from an async code just use spawn_blocking.

https://docs.rs/tokio/latest/tokio/task/fn.spawn_blocking.ht...

Re:Chris Lattner left Swift core team by ithkuil on Wednesday February 23, 2022 @12:24PM (#30443611)
Yes you can. And this will create threads on demand as needed.

But you need to know when you must call this and when it's ok to not call it.

The type system won't help you with that. But if you forget to call it you can cause starvation and if you call it too often you may create too many threads.

What I see in the ecosystem is that such tricks are perceived as hacks and that it would be just better if one could just write a pure rust reimpl.

Surely there are enough reasons that drive people to reimplements stuff in rust. I think this aspect of async nudges people even further into that though.