Earlier quoted context omitted.
Not possible for the same reasons why just adding a borrow checker to C++ isn't possible. Mostly this comes down to incompatibility with existing code. Zig is just not memory safe, and the only solution would be to add a GC.
This is a very bad take. By your argument there's no reason why sel3 should exist, which is written in C and safer than rust.
Why asynchronous Rust doesn't work
301–305 of 305 posts
Re: Why asynchronous Rust doesn't work
#302Earlier quoted context omitted.
Not possible for the same reasons why just adding a borrow checker to C++ isn't possible. Mostly this comes down to incompatibility with existing code. Zig is just not memory safe, and the only solution would be to add a GC.
If you don't consider Swift style Automatic Reference Counting a GC, then there is another option.
Re: Why asynchronous Rust doesn't work
#303Earlier quoted context omitted.
I don't use Rust but was curious if this was a real or imagined problem--it seems to be the latter. Two points: 1. the example could have made a pure callback function that takes a mut& db param and pass thaf param to the 'do'er function. Why is this not required anyway? i.e. How does Rust know/decide who owns the mut& db if both the closure and the function that creates the closure can reference it? 2. as mentioned,…
> the example could have made a pure callback function that takes a mut& db param and pass thaf param to the 'do'er function. No. If you did that, you could only pass functions in that took the db as a closure argument, nothing else... you're thinking about this example only, and forgetting the problem is with the general case of capturing whatever is needed for the callback to work.
Re: Why asynchronous Rust doesn't work
#304Earlier quoted context omitted.
I've found async to be straight forward anytime I've used it. Promise#then is equivalent to callbacks async/await often requires very little changes compared to synchronous code, whereas reworking a program into callbacks is much more impactful. & the async/await compilation process tends to produce better performance in addition to this. My first async/await work was a few years ago to increase a data importer's per…
> the caller fires it off without a ticket to wait on the result Exactly! Making a thread block waiting for a result isn't true async in my book. It doesn't matter that the result is going to come from another thread. Futures/Promises make you block a thread.
Performance numbers don't care what's in your book
Re: Why asynchronous Rust doesn't work
#305Earlier quoted context omitted.
I can't speak authoritatively, but I can think of some good reasons you might not want to automatically and implicitly await every invocation of an async function. As designed, calling an async function just returns a Promise, and any Promise can be awaited. This means that I can pass that Promise around, and it also means I can use a Promise-based library (of which there are many) easily from within my async code. A…
All right more flexibility, good point. However what languages are you thinking of when talking about this? I've done a lot of Java programming where we commonly use threads and thread pools, although there are non blocking libraries out there too. Is it common these days to mix promises and threads (waiting on a promise in a thread), or is what I just said nonsense?
More generally, I don't have a good enough overview of programming language trends to speak to how that fits in with other languages' approaches to async.
> Is it common these days to mix promises and threads
I'm not sure. That probably depends a lot on the evolutionary history of a given language and its library ecosystem.
I could see it being done to mix those two things in a world where you are trying to glue together two libraries (or legacy internal modules) built in different ways, and the alternatives either don't exist or are more onerous.