Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Where did it come from in its current incarnation? Node.

Rust's async/await is inspired by C# (which was inspired by F#, which was inspired by Haskell).

> right now threaded code is straight-up a better option on almost every metric,

Agreed that people are generally too eager to reach for async when they could easily get away with threads, and fortunately Rust makes threads extremely pleasant to work with. The whole point of Rust is that it doesn't force you to use any given paradigm when it comes to concurrency/parallelism, and has support for many approaches.



And yet it didn't learn that it took almost 10 years for .NET community to sort out async/await support across all layers of the stack.

.NET archictects have spent last year researching Go and Java Loom approaches, and have acknowledge if it had been today, most likely that would have been the approach taken instead of async/await, as many .NET devs still get it wrong.

During the "ASP.NET Core and Blazor futures, Q&A" at BUILD 2023.

This is the best practices of async/await in .NET as written by one of the ASP.NET architects,

https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/b...


Everyone rediscovers Erlang at one point in this space, it seems.


Yeah, it would be great if it had wider industry adoption.


Joe Duffy on Midori and async/await in a C# dialect: http://joeduffyblog.com/2015/11/19/asynchronous-everything/


Where he notes that the .NET implementation wasn't without issues on Midori.

Which is again another point of how the whole Rust's async/await process failed to learn from previous experiences.

Even worse, because in what concerns .NET, the runtime is part of the story, while in Rust that is yet another piece of the puzzle that is in motion, not yet decided, although it can be anything as long it is tokio.


> Where he notes that the .NET implementation wasn't without issues on Midori.

Indeed. In my opinion and experience async/await is a very leaky abstraction. I think it is definitely not worth it in most languages. Whether it is appropriate for rust I'm unconvinced. I think it is DOA in C++ with its required allocation, but I have yet to use it in anger.


I only have used them in C++/WinRT, as they are a kind of required to handle anything WinRT, and it was kind of ok when doing UWP, although it was much more complex as in WinRT case, it also takes into account how COM/WinRT compartments work.

See https://devblogs.microsoft.com/oldnewthing/20210504-01/?p=10...

Don't miss it.


See other post about why I blame node.

As for Rust supporting threads... yes! Yes it does! And it effectively solves all of the problems with them that can be solved at the programming language level. There's an irreducible increase in complexity with concurrent code, but there's only so much to be done about that.

I think a lot of developers have a tendency to massively overprivilege performance and always reach for the biggest, shiniest thing when they don't need it, and cost themselves a lot in the process. Sure, if you're doing tens of millions of things concurrently in Rust you may need the async support because threads can't do what you want. But before you write code based on the assumption that you're going to be doing tens of millions of concurrent things on a 64-core system, check that you actually are. If you've got an API server whose request rate is measured in tens per second, a really quite common case, you'll never notice the thread overhead. You really need quite a massive system nowadays to get to the point where that's even remotely a problem, let alone your biggest one.

I don't deny that when you are nailed to the wall and seriously wondering if 64 cores is going to be enough you may have specialized needs that require specialized solutions. I am glad that Rust has the option for those who need it. But async should be counted as a cost of such problems, not a benefit, and something you prove out as the only solution, not the first thing reached for.


It is the mindset that makes one buy a SLR, when they can't even make up all the options on the smartphone camera.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: