Hacker News new | comments | show | ask | jobs | submit login

I don't agree that async/await is in "should know" and LINQ is in "nice to know".

LINQ took C# from MS's Java clone with nicer generics to one of the best languages out there. It is phenomenal for increasing developer productivity.

Async/await, while a nifty, sometimes useful addition, is overhyped, code-complicating, unnecessary for most programmers, adds almost no performance benefits to most programs and infects the call stack above and below it with debugging problems, bad stack messages and extra code. It can introduce subtle and very nasty bugs, as well as impeding your ability to code some common patterns.

Why they keep pushing it as if every tom, dick and harry should write all their code using it, I do not know. It has a price so you should only use it when it's actually useful.

LINQ (the syntax) is borderline useless in a post-lambda C#. The query expressions don't fit with the rest of your code well, and it makes it unclear that you're calling library code to perform the query. LINQ (the standardized collection library) is amazing to work with, very powerful, and most importantly of all, very intuitive and discoverable (thanks to great IDE support from Microsoft). You don't need to take a course to use learn to use the basics of LINQ's Enumerables - I would even suggest that most novice C# programmers start using it without even realizing they're doing so.

Async/await, just like query expressions, are a syntax construct - they are something that is difficult to discover. You don't find it in the auto complete list in the IDE (usually). This is why you need to learn about it to use it at all, let alone use it correctly, hence why it should be in the top things a modern C# dev needs to actually learn about - since the upsides for using it correctly are so great (code clarity), and the alternatives are so poor (chained tasks? managed threads? All comparable minefields that are difficult to grok). Plus, all the "call stack problems" you claim are inherent to any asynchronous tasks in C# - async/await actually gives your better traceability and debugging across asynchronous operations than any alternative.

So yeah, I'd say in terms of actual learning, knowing what/how/why for async/await is much more important than from/in/where/select (which you can forget using and just use the more discoverable library methods instead).

Doesn't Async/Await help dealing with nested callbacks and simplify exception handling? I wouldn't push everyone to use it. But it is really useful in a lot of places. I cannot imaging writing Xamarin apps and distributed cloud services without it.

It certainly does help, but it's also (IMO) not a pattern to be adopted without some forethought, especially if want to mix async and sync style patterns. In practice, I have usually seen people go (mostly) all in on one or the other.

I disagree that it doesn't add to most programs... it absolutely does as most programs are deployed web applications and use of async/await affects the number of users/requests a server can support dramatically.

Of all the .Net web apps I've worked with I've seen an app maxing out IIS threads once, but I've seen plenty of web apps with shitty SQL queries maxing out the SQL server.

I've admittedly never had the 'millions of requests per second' clients, but the number of available threads has never been remotely the problem.

Back in 2006/2007 we had one app maxing out the IIS threads, but that was back when there were 100 threads max (as far as I can remember, might be wrong) and the actual underlying problem was slow SQL requests. Temp fix was to up the IIS threads, but once we fixed the SQL problem, no need for those extra IIS threads any more.

And even then, what will implementing async/await get you that you couldn't fix with a load balancer and web farm? Web farm is cheaper, easier and more effective. I think there's a Jeff Atwood piece somewhere on coding horror, or maybe a Joel one, to that exact effect. Cheaper to throw hardware at it then dev time. There's a certain scale that async/await actually fixes, the vast majority of C# web apps won't ever get close to it.

Every client I've taken on who were having performance problems were always fixed by monitoring SQL and fixing the bad queries. Or it was stupid loops calling moderately expensive SQL that did the same query over and over. Or something that could be easily cached. Or the same query being called several times in a stack where you could easily just pass the result down. One of those clients even had a previous dev who went async/await happy for extra 'performance' and it did zip. I ended up ripping most of it out, as I said, it infects code up and down the stack and complicates the code. All the 'optimized' async code was taking 1-2 milliseconds to run while the problem SQL was taking 5-10 seconds.

In a web app I can see the need if you're doing lots of external requests

What it gets you is not having to run as many servers... I've worked on IIS apps that required 6+ servers to handle high load, and that was before async was available, Similar situations could reduce the servers needed to 3-4. But agreed, in most situations it may not be needed... However, if you're in an org an want multiple apps per server/cluster then it benefits all the other applications.

I've seen far more issues with people not understanding how to use static and how it applies in a web application.

But most programs written are internal corporate apps at SMBs, and async/await isn't needed at that scale.

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