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

That's a good article. And yes, async is totally viral. Once you start using it, everything becomes async if you like it or not. I definitely need to study Go and goroutines. They seem to have a better approach.



There is no good approach to avoiding asynchrony. There's been nothing new in this department for decades. You have these choices:

     - async, continuation passing style code
     - async with delineated continuations to make snippets look synchronous which aren't actually
     - cooperative multi-tasking (co-routines with async I/O under the covers)
     - threading (preemtible multitasking)
Each one of this choices has its problems, and all can be characterized as where on the spectrum of explicit vs. implicit state keeping you want to be. For example, with threads and co-routines you keep a lot of implicit state in the call stack, whereas with async CPS you make all of the state fully explicit. Async CPS code is the least problematic once you wrap your mind around it, but it does have "mind warp" as a hard requirement.

There are times, of course, when your code is very serial, and then you really do benefit from co-routines/threads. For example, PuTTY's implementation of the SSH version exchange, key exchange, and user authentication protocols, is one HUGE C function that is actually running as a co-routine which cooperates with the UI side, with async I/O under the covers. The PuTTY approach is wonderful for that particular case: those parts of the SSH protocols are extremely serial, and the resulting serial-looking code is very very easy on the eyes (so much so that it makes up for the enormity of the function that implements it!). So it pays to be able to reach for co-routines sometimes, but not always, and I'd say not even most of the time.

Programmers today simply have to be prepared to deal with everything-is-async codebases, and they should be prepared to create codebases where everything is async from day zero.


I believe the "programmers should be prepared to deal with async codebases" is purely an engineering issue and async is a question of providing the necessary syntactic tools in order for them to achieve that.

There's nothing special about "async" per se. What about people writing OS code in the 90s? They didn't even hear about async and the "sync" was invented for the sake of easier control over the time shared between processors (remember all of our implementations of processes in OSs are CPS-style, where they just give up the control over their stack if run for more than X ms).

Other thing I do recently consider a lot is asynchronicity between machines: 1) receive a request 2) send a database request 3) return an error if database request had timed out ...) etc. Having a language that spans several systems, enveloping time, execution redundancy contraints and ensuring data passed is not garbage is something that would be novel.


"syntactic tools" -> implicit state.

There's only so much the compiler can do for you. At some point you have to bear some of the cognitive load of state compression (which is really all async is about).

Multi-processing was great, but it doesn't scale to today's world, and neither does multi-threading. It doesn't matter in the least that those two technologies allow the programmer to write serial-looking code that does not execute serially. Those technologies cannot compress program state embodied in the call stacks and heap, therefore they do not scale (because they consume too much memory, have worse cache footprints and higher resident set size, involve heavy-duty context switching, and so on).

In terms of actual novelty in this space in computer science, I don't believe there's been anything new since the 80s. Everything that seems to be new is an old idea rediscovered, or a new take on an old idea, so either way not new at all.

CPS -> least implicit state.

Process -> most implicit state.

In between those two there are a few options, but nothing is a panacea, and ultimately CPS is an option you have to be prepared to use.

Less implicit state -> explicit state, which you can compress well because you understand its semantics.

Less state -> less load for the same work -> more work can be done.

In some contexts (e.g., the UI) this is a very big deal, which is why GUIs are async.




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

Search: