Originally posted by bug77
View Post
Announcement
Collapse
No announcement yet.
Rust 1.39 Released With Async-Await Support, Attributes On Function Parameters
Collapse
X
-
Originally posted by DoMiNeLa10 View PostAsync await is pure cancer no matter the language. It makes code convoluting, error handling becomes flimsy and cumbersome. Implementing a proper monadic interface is the way to go.
A pragmatic new design for high-level abstractions Monads (and, more generally, constructs known as “higher kinded types”) are a tool for high-level abstraction in programming languages1. Historically, there has been a lot of debate inside (and outside) the Rust community about whether monads would be a useful abstraction to have in the language. I’m not concerned with that here. You see, there’s a problem with talking about whether monads would be useful or not, and it’s this: there are a large number of design challenges to overcome to have any hope of implementing them at all — to the best of my knowledge, there currently exists no realistic (that is, practical) design for monads in Rust. In fact, there are so many obstacles that some people express doubt that it’s even possible. Strictly speaking, they’re a lot more than that, but we’re only interested in the programming angle here. ↩
I also recommend reading the Twitter thread it links to when it says "In fact, there are so many obstacles that some people express doubt that it’s even possible."
- Likes 1
Comment
-
Originally posted by Khrundel View PostYou must be kidding. Js have got async/await only recently. Async/await was invented because synchronous IO has disastrous performance. Node.js were outperforming Asp.net and MS had to do something, that is why they've invented sugar to hide callback chain behind pseudosynchronous code.
For example, before async / await existed, Javascript in a web browser environment couldn't do synchronous IO. The only exception was a synchronous ajax request which most browsers didn't allow anyway and it has been deprecated.
Synchronous IO is still the *only* way that io can be performed underneath if you do not have proper multithreading (i.e JS web browsers). You just read in small chunks and poll. It only has disastrous performance if the developer doesn't quite have enough experience.
Comment
-
Originally posted by kpedersen View Post
Agreed, it doesn't work well in game loops or other real-time systems.
It was only invented and became popular because of the limitations of web browser environments. If Javascript interpreters were correctly multithreaded from the start and didn't freeze the browser on a tightloop, callbacks calling callbacks calling callbacks would remain a niche clusterfsck left entirely to amateurs.
The way I got it, by way of a C analogy, would be with each "async" variable being a structure with a function pointer, as well as that function's parameters (not sure if any global scope is preserved as well), to be called at a later point. That, without the runtime overhead of such a structure. But I could be wrong, and I would actually like a primer for that feature written in those terms, if anyone has a few pointers?
Yeah, I should really take time to learn Rust properly one of these days...
Comment
-
Originally posted by [email protected] View Post
I have never used async/await, doing mostly system/embedded programming in C. There, you can have an event loop, and handle asynchronous computing trough a few synchronization primitives. But from what I've seen with rust, it's basically syntaxic sugar, and I am not sure there is a reason why the way it was implemented in rust would be incompatible with game loops and other real-time systems.
The way I got it, by way of a C analogy, would be with each "async" variable being a structure with a function pointer, as well as that function's parameters (not sure if any global scope is preserved as well), to be called at a later point. That, without the runtime overhead of such a structure. But I could be wrong, and I would actually like a primer for that feature written in those terms, if anyone has a few pointers?
Yeah, I should really take time to learn Rust properly one of these days...
He is currently working on something called "Session Types"; a way of logically representing types in concurrent systems, if you will.
https://homepages.inf.ed.ac.uk/wadle...s-sessions.pdfLast edited by fuzz; 08 November 2019, 02:26 PM.
Comment
-
Originally posted by kpedersen View Post
I more meant an asynchronous architecture in general. Those keywords are basically just syntactic sugar anyway.
For example, before async / await existed, Javascript in a web browser environment couldn't do synchronous IO. The only exception was a synchronous ajax request which most browsers didn't allow anyway and it has been deprecated.
Synchronous IO is still the *only* way that io can be performed underneath if you do not have proper multithreading (i.e JS web browsers). You just read in small chunks and poll. It only has disastrous performance if the developer doesn't quite have enough experience.
These days, multithreaded js in a browser is a thing with web workers. Applications like Google Maps are multithreaded, and you can just go there to check it yourself with dev tools in your browser.
Comment
-
Originally posted by kpedersen View Postcallbacks calling callbacks calling callbacks would remain a niche clusterfsck left entirely to amateurs.
- Likes 3
Comment
-
Originally posted by Ilphrin View PostThat's a lot of good news! I tried Rust when in was in beta, and that was painful but cool (I feel weird to say that), should give Rust another try now. Just need a project excuse to code in Rust
Last edited by oleid; 08 November 2019, 03:48 PM.
Comment
-
Originally posted by DoMiNeLa10 View PostAsync await is pure cancer no matter the language. It makes code convoluting, error handling becomes flimsy and cumbersome. Implementing a proper monadic interface is the way to go.
The below async code:
Code:let mut buf = String::new(); File::open(path) .await .context("failed to open file")? .read_to_string(&mut buf) .await .context("failed to read file");
Code:let mut buf = String::new(); File::open(path) .context("failed to open file")? .read_to_string(&mut buf) .context("failed to read file");
Last edited by mmstick; 09 November 2019, 12:23 AM.
Comment
-
Originally posted by kpedersen View PostSynchronous IO is still the *only* way that io can be performed underneath if you do not have proper multithreading (i.e JS web browsers). You just read in small chunks and poll. It only has disastrous performance if the developer doesn't quite have enough experience.
Comment
Comment