113 votes
Accepted

Is there really a fundamental difference between callbacks and Promises?

It is fair to say promises are just syntactic sugar. Everything you can do with promises you can do with callbacks. In fact, most promise implementations provide ways of converting between the two ...
Ixrec's user avatar
  • 27.7k
106 votes

Are events only used for GUI programming?

Nope. They're really handy for implementing Observers and making sure that classes are closed to modification. Let's say we have a method that registers new users. public void Register(user) { ...
RubberDuck's user avatar
  • 8,921
67 votes
Accepted

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Async/await is exactly that automated management that you propose, albeit with two extra keywords. Why are they important? Aside from backwards compatibility? Without explicit points where a ...
amon's user avatar
  • 133k
64 votes
Accepted

Who did async/await first?

Haskell (2012) There is an async package for Haskell (2012) by Simon Marlow. In case you don't know, Simon Marlow is a lead developer of Haskell. Notes: Simon Marlow joined Microsoft research in 1998 ...
Theraot's user avatar
  • 9,041
53 votes

Are events only used for GUI programming?

Nope. A classic example of events being used in non-GUI logic are database triggers. Triggers are code that gets executed when a given event happen (INSERT,DELETE, etc). Seems like an event to me. ...
Tulains Córdova's user avatar
27 votes

Are events only used for GUI programming?

Event-based programming is actually also used for highly performant server programming. At a typical server workload, much of the time processing a result actually comes from I/O. For example, ...
ArTs's user avatar
  • 720
27 votes

Why don't programming languages automatically manage the synchronous/asynchronous problem?

What you are missing, is the purpose of async operations: They allow you to make use of your waiting time! If you turn an async operation, like requesting some resource from a server, into a ...
cmaster - reinstate monica's user avatar
22 votes
Accepted

Is the C# async/Task construct equivalent to Java's Executor/Future?

C#'s Task is somewhere halfway between Java's Future and CompletableFuture. The Result property is equivalent to calling get(), ContinueWith() does the things the massive array of continuation ...
Sebastian Redl's user avatar
19 votes

Calling multiple async services in parallel

One issue I see using Task.WhenAll is that it does not return results But it does return the results. They'll all be in an array of a common type, so it's not always useful to use the results in ...
Servy's user avatar
  • 1,966
18 votes

Does Akka obsolesce JMS/AMQP message brokers?

Actor Model The actor model is computer science strategy for building applications that handle lots of concurrent computation and stateful processing. It's not the only strategy but it's a very well ...
Mani Gandham's user avatar
18 votes

Why is there a shift towards asynchronous and event driven programming?

The "async" approach better facilitates human reasoning. When most people drive, they don't need to concern themselves with how every element of the car is interacting. Forget the tires - ...
TheRubberDuck's user avatar
14 votes
Accepted

Using asynchronous calls for heavy IO operation: How to prevent crushing the CPU?

While you may have 4 CPUs, you have only one hard-drive (unless you don't). The total performance will therefore be limited by your disk drive's read/write rate. Multiple threads isn't going to change ...
Nicol Bolas's user avatar
  • 11.9k
14 votes

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Some do. They're not mainstream (yet) because async is a relatively new feature that we've only just now gotten a good feel for if it's even a good feature, or how to present it to programmers in a ...
Telastyn's user avatar
  • 109k
13 votes
Accepted

"Reactive programming is programming with asynchronous data streams." is this true?

The most common example of Reactive programming that I've heard about is a spreadsheet program that has computed values. Personally, I would think about a spreadsheet more as a hybrid between ...
Jörg W Mittag's user avatar
13 votes

Why don't programming languages automatically manage the synchronous/asynchronous problem?

There are languages that do this. But, there is actually not much of a need, since it can be easily accomplished with existing language features. As long as you have some way of expressing asynchrony,...
Jörg W Mittag's user avatar
13 votes

Why is it necessary for every new api to be async?

I feel that c# has become a very wordy language and I'm not happy to have to code in the async style like this. Oh, but that is not wordy at all. You are not writting something like this: client....
Theraot's user avatar
  • 9,041
12 votes

API Gateway (REST) + Event-Driven Microservices

Repeat after me: REST and asynchronous events are not alternatives. They're completely orthogonal. You can have one, or the other, or both, or neither. They're entirely different tools for ...
Jack's user avatar
  • 4,449
10 votes

Are events only used for GUI programming?

Events are also heavily used in network programming (e.g. Nginx) to avoid expensive busy-wait loops and instead provide a clean interface to know exactly when a certain operation is available(I/O, ...
edmz's user avatar
  • 201
10 votes

How can message queues improve scalability?

It's not that queues are more scalable, its the fact that two services communicating through queue means the communication is asynchronous. Asynchronous communication is far more scalable than ...
Matan Shabtay's user avatar
10 votes

Why is there a shift towards asynchronous and event driven programming?

Fundamentally the answer comes down to the fact that threads are not free. There is overhead associated with each thread. I found this article which is written by former Intel Engineer Arch D. ...
JimmyJames's user avatar
  • 25.9k
8 votes

Why is there a shift towards asynchronous and event driven programming?

A lot of event driven programming is because the applications are event driven. You're running code to handle a button click, or a received packet, or a timer expiring. That sort of code is actually ...
Karl Bielefeldt's user avatar
7 votes
Accepted

Trying to understand some async/await behavior

When you call it like this: await GetChecksum(1,@"E:\Files\ISO\5gbfile.iso"); await GetChecksum(2,@"E:\Files\ISO\4gbfile.iso"); await GetChecksum(3,@"E:\Files\ISO\3gbfile.iso"); await GetChecksum(4,@"...
Karl Bielefeldt's user avatar
7 votes

async+await == sync?

I stumbled on this with the same question in mind, yet after reading the responses the question seems to linger, confused by references to "magic under the hood". From the above-mentioned ...
oversynched's user avatar
7 votes
Accepted

What is the functional programming method for combining two "streams" of data?

This is where the monadic properties of Eithers come in handy (although you don't have to understand monads to take advantage of them). Most functional programming languages have a way to easily ...
Karl Bielefeldt's user avatar
7 votes

Why don't programming languages automatically manage the synchronous/asynchronous problem?

They do (well, most of them). The feature you're looking for is called threads. Threads have their own problems however: Because the code can be suspended at any point, you can't ever assume that ...
user253751's user avatar
  • 4,863
6 votes
Accepted

Do any languages have syntax for promises?

Yes, there are several such languages: C# has async methods and the await keyword. Technically speaking, any object which implements a certain syntactic pattern can be awaited, but the intention is ...
Jörg W Mittag's user avatar
6 votes
Accepted

Does omitting await keyword once in the call stack break the asynchronous behavior of the whole stack?

In .net the async await keywords are an extension of the Task Parallel Library. When you do not await an async method it is almost equivalent to calling Task.Run(()=>A()) (There are some gotchas ...
RubberChickenLeader's user avatar
6 votes
Accepted

Is there a pattern for a chain of asynchronous calls, followed by a cleanup?

You can use a promise chain like the idiomatic q one, roughly: doSomethingThatReturnsAPromise .then(function (result, error) { if (error) { [the previous command failed in ...
l0b0's user avatar
  • 11.3k
6 votes

What happens in terms of call stacks when 10000 setTimeouts are called?

For your custom programming language, the answer is "whatever you want it to be". Once you've defined your execution model, that will tell you what your call stacks look like. In particular ...
Philip Kendall's user avatar
5 votes

Are events only used for GUI programming?

Embedded systems are almost always inherently event-driven, even if they are not programmed explicitly as such. These events come from things like hardware interrupts, button presses, period analog-...
Radian's user avatar
  • 797

Only top scored, non community-wiki answers of a minimum length are eligible