Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the new async and await keywords in ES7 copied from C#? [closed]

Noticing that async and await aren't found in Java, where these new keywords in ES7 copied from the C# language? I'm curious as to the origin: Who proposed the keyword names and is someone in the JS community is leveraging concepts from the .NET framework?

like image 288
sean2078 Avatar asked Dec 10 '15 16:12

sean2078


People also ask

Is async await on the same thread?

The async and await keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active.

Are async and await keywords in JavaScript?

JavaScript await Keyword The await keyword is used inside the async function to wait for the asynchronous operation. In the above program, a Promise object is created and it gets resolved after 4000 milliseconds. Here, the asyncFunc() function is written using the async function.

What is async and await keyword in C#?

The async keyword turns a method into an async method, which allows you to use the await keyword in its body. When the await keyword is applied, it suspends the calling method and yields control back to its caller until the awaited task is complete. await can only be used inside an async method.

Does await Block C#?

When the await operator is applied to the operand that represents an already completed operation, it returns the result of the operation immediately without suspension of the enclosing method. The await operator doesn't block the thread that evaluates the async method.


1 Answers

The concept of using promises (or futures, etc.) is becoming more and more popular, but it isn't new. You can find it in MultiLisp for example.

The async and await keywords however were used recently in C# and now are spreading into many other languages.

Several mainstream languages now have language support for futures and promises, most notably popularized by the async and await constructions in .NET 4.5 (announced 2010, released 2012) largely inspired by the asynchronous workflows of F#, which dates to 2007. This has subsequently been adopted by other languages, notably Dart (2014), Python (2015), Hack (HHVM), and drafts of ECMAScript 7 (JavaScript), Scala, and C++.

So yes, JS is borrowing from C#.

From Futures and promises#History

like image 107
i3arnon Avatar answered Oct 05 '22 10:10

i3arnon