News for hackers. Stuff that matters.
Re:Comparison of Rust async and Linux thread context switch ... by kzrdude on Friday February 12, 2021 @04:10AM (#26111858)
That's interesting to hear - but how much of an investment is it to climb the that mountain (or hill) that makes you comfortable with working with the async model?
Re:Comparison of Rust async and Linux thread context switch ... by lxpz on Friday February 12, 2021 @08:40AM (#26113502)
I'm not the best qualified to answer this question as I do spend a lot of time reading about programming languages in general, and even though I was able to grasp Rust's async/await very fast, I probably owe it to previous knowledge of a relatively large variety of programming paradigms. I'll thus rely on other commenters that seem to agree that it's really not as hard as you would expect. In particular Rust helps a lot in making sure you don't make too many mistakes so I'd wager that learning to do correct async/await in Rust is probably easier than in, say, Javascript.
Re:Comparison of Rust async and Linux thread context switch ... by pas on Friday February 12, 2021 @05:12AM (#26112111)
Rust's async model takes very little time to grasp. It's very explicit. Nothing runs in the background (contrast that with NodeJS). You have strong static types to help you to know when you got a Future, you can decide where/when to await it.

It's programming with threads, where you have a thread pool and pipes to put tasks onto that and a helper function/macro. Await does this under the hood of course.

Re:Comparison of Rust async and Linux thread context switch ... by baby on Friday February 12, 2021 @06:17AM (#26112451)
That is until you get a weird error or try to do something more complicated.
Re:Comparison of Rust async and Linux thread context switch ... by pas on Friday February 12, 2021 @07:42AM (#26113014)
This is perfectly valid for NodeJS, Python (async and/or threads, hello GIL[0]), and a host of other languages/runtimes.

Also I agree that multi-threaded Rust is probably the best alternative to async Rust.

[0] I have no problems with the GIL, but it's yet another factor to consider when a python multi-threaded program stops working as intended

Re:Comparison of Rust async and Linux thread context switch ... by EugeneOZ on Friday February 12, 2021 @09:19AM (#26113868)
Not sure how you can compare then. You can’t do with the threads what you can do with async functions.
Re:Comparison of Rust async and Linux thread context switch ... by pas on Saturday February 13, 2021 @01:04PM (#26125304)
?

You can do exactly the same thing, after all async is just a big auto-generated state-machine that puts jobs onto a thread pool and waits for them.

Nginx is hand crafted (artisanal!) event-driven C, which is exactly how async runtimes also work. A big loop (the event loop, usually an infinite `while` blocked on epoll()). For example NodeJS uses libuv for this.

The big advantage of first class async support is that we don't have to do this by hand. Plus it makes some optimizations easier (eg. putting things on the stack instead of assigning each event handler a slice of some global [heap allocated] structure).

Or maybe I'm simply misunderstanding what you meant. In that case cloud you clarify please?

Re:Comparison of Rust async and Linux thread context switch ... by TheNorthman on Friday February 12, 2021 @04:27AM (#26111929)
Not OP but: I found it surprisingly manageable. I think the disconnect for many people is they think they'll understand it simply by using it [0]. For me, investing a short time reading some of the design articles/documents really helped it click.

[0]: Which is fair, I wouldn't be surprised if this was the best way for some.