Live data from Hacker News

Async might be a fad

cs.oswego.edu

61–70 of 76 posts

Re: Async might be a fad

#61

Earlier quoted context omitted.

"My point is, move these IO actions to another thread; the code in that thread is good old synchronous/threaded code." Sure. But how do you handle that? IO results need to be communicated back to the UI thread somehow. Throwing together a whole new thread+stack against a named method that communicates back via explicit messages (or however you want to get the results of IO back to the UI thread) seems like a bit much…

There is no problem to modify UI state from any thread; just put up some synchronizations. The hard part is, if the modifications do not form a single, predictable, serialized chain, how can the programmer reason about them? This problem is independent of async/sync. If you use C# async for a UI action, you still need to worry about it.

> There is no problem to modify UI state from any thread; just put up some synchronizations.

It reminded me of the "I know, I'll use regular expressions" joke.

Re: Async might be a fad

#62
post #58

Earlier quoted context omitted.

I agree, async is needed sometimes. Another example, a server broadcasts an event to multiple clients (e.g. a chat app), it would be silly to spawn a thread per client for that.

But the whole point of async is that, after data is dispatched the client moves on. I'm not sure what NodeJS does with it but this is my interpretation of the concept. I don't think people who know what they are doing, use async calls for mission critical operations. If async call returns response and client is required to read the response it's no longer considered non-blocking from technical perspective.

[deleted]

Re: Async might be a fad

#63

Earlier quoted context omitted.

How do you define "async" that excludes Go?

I use the word from the programmer's point of view; it's irrelevant how things are done under the hood. For example, in Go, when you read a value from a channel, it's just like a good old blocking call, as far as the programmer is concerned. On the other hand, an "async" read would involve callback, promise, or some other constructs.

Promises are also like good old blocking calls. How is a channel different?

Re: Async might be a fad

#64

Earlier quoted context omitted.

How do you define "async" that excludes Go?

I use the word from the programmer's point of view; it's irrelevant how things are done under the hood. For example, in Go, when you read a value from a channel, it's just like a good old blocking call, as far as the programmer is concerned. On the other hand, an "async" read would involve callback, promise, or some other constructs.

[deleted]

Re: Async might be a fad

#65
post #61

Earlier quoted context omitted.

There is no problem to modify UI state from any thread; just put up some synchronizations. The hard part is, if the modifications do not form a single, predictable, serialized chain, how can the programmer reason about them? This problem is independent of async/sync. If you use C# async for a UI action, you still need to worry about it.

> There is no problem to modify UI state from any thread; just put up some synchronizations. It reminded me of the "I know, I'll use regular expressions" joke.

The single-event-thread design is not without its own problem; programmers have difficulty in understanding and abiding to it too.

Here we have an inherently concurrent problem - user actions and some IO actions occur concurrently. That problem cannot be reduced by some API or language trick.

Re: Async might be a fad

#66
post #53

Earlier quoted context omitted.

I don't think you've seen truly great async support, it's virtually indistinguishable from sync code. Sync: let file = File.Open("foo.txt") let data = file.Read(8192) // Do some compute stuff with data ASync: let! file = File.OpenAsync("foo.txt") let! data = file.ReadAsync(8192) // Do some compute stuff with data

while the syntax can be as simple as that, there is still a difference, and the programmer still needs to be very careful. what if you accidentally forget the `"!"`?

Umm... it doesn't compile because it's the wrong type...

But yeah multithreading is easy.

Re: Async might be a fad

#67
post #61

Earlier quoted context omitted.

> There is no problem to modify UI state from any thread; just put up some synchronizations. It reminded me of the "I know, I'll use regular expressions" joke.

The single-event-thread design is not without its own problem; programmers have difficulty in understanding and abiding to it too. Here we have an inherently concurrent problem - user actions and some IO actions occur concurrently. That problem cannot be reduced by some API or language trick.

> The single-event-thread design is not without its own problem; programmers have difficulty in understanding and abiding to it too.

Definitely not my experience. jQuery is very popular among unskilled programmers because its async model is very easy to understand. I use it to teach async!

> That problem cannot be reduced by some API or language trick.

Why? Reducing problem by API or language tricks is exactly what abstraction is for.

Re: Async might be a fad

#68
post #61

Earlier quoted context omitted.

> There is no problem to modify UI state from any thread; just put up some synchronizations. It reminded me of the "I know, I'll use regular expressions" joke.

The single-event-thread design is not without its own problem; programmers have difficulty in understanding and abiding to it too. Here we have an inherently concurrent problem - user actions and some IO actions occur concurrently. That problem cannot be reduced by some API or language trick.

Given the Universal Turning Machine and the Church-Turing thesis in actuality all of programming except for assembler is pretty much some API or language trick.

Re: Async might be a fad

#69
post #68

Earlier quoted context omitted.

The single-event-thread design is not without its own problem; programmers have difficulty in understanding and abiding to it too. Here we have an inherently concurrent problem - user actions and some IO actions occur concurrently. That problem cannot be reduced by some API or language trick.

Given the Universal Turning Machine and the Church-Turing thesis in actuality all of programming except for assembler is pretty much some API or language trick.

Arguably, even machine language is "some API" and assembler "some language trick".

Re: Async might be a fad

#70

I don't write web applications, and I don't use much JavaScript, so it's very possible that I don't properly understand the motivation for this blog post. However, as others have said there is a difference between some inconvenient syntax in JS, and the fundamental model of non-blocking I/O. What I do write is lots of C/C++ client/server applications for HPC/HFT/DC workloads where speed both in req/sec (throughput) a…

I apologize for the sensational and generalizing title. What I'm talking about is focused on web applications, and from empirical data, it seems that most web servers handle very few concurrent requests, therefore it would be silly to go all async to avoid threads. I'm very surprised that many people here argue that async code is much better to understand than sync code. Ok, so that part is subjective, and let's file…

'What I'm talking about is focused on web applications, and from empirical data, it seems that most web servers handle very few concurrent requests, therefore it would be silly to go all async to avoid threads.'

It might be an idea to look at this 'empirical' data and figure out which webservers use forking/threads and which use events/async, then you may realize why the high concurrency webservers took the 'silly' route of avoiding threads.

Post reply on HN