logoalt Hacker News

torginus • yesterday at 2:44 PM • 4 replies • view on HN

I am a bit skeptical of the non-blocking claims, as actor systems usually make several tradeoffs, that handle the classical 'blocking' issue differently (by which I mean I read a 100MB file synchronously on the UI thread, and the program appears to freeze).

Classical actor systems at their simplest only support sending one-way messages, and these are indeed non-blocking.

But they are not very powerful either. People usually introduce the 'remote procedure call' on top of this, by which actor A can call actor B and expect B to respond. You can do this with corellation IDs for example.

The question is what does actor A do while waiting for 'B'? In the simplest form it continues to serve other messages, making the actor reentrant, which can create incredibly surprising scenarios as code executes while you don't expect to changing actor fields in unexpected ways.

Or you can have actor A wait to finish processing the call to 'B'. But now you have blocking, as 'B' can prevent anyone talking to 'A' from making progress.

Or you can do something computer-sciencey, like doing transactions and specifying the conditions under which A can server multiple ongoing requests, and how to reconcile them.

I'm sure there are many options, but actors have been a cool idea for a while, and many event driven paradigms borrow from it, that are incredibly widespread to the point that I'm sure most people have programmed in a system before, and have experienced 'callback hell'.

So they are not a panacea.


Replies

gwbas1c • yesterday at 4:42 PM

You are right. I inherited an early version of a product built in the Actor model, and we quickly had to go to a hybrid approach doing some of the things you describe.

Specifically, we introduced a single actor that manipulated shared state and was responsible for some critical IO. Other actors could see the shared state in a non-blocking manner, so there ended up being a lot of "refresh my shared state" or "abort if the shared state changed".

My longer-term conclusion was that the actor model wasn't correct for the product, because it obscured the procedural nature of what happened in each operation. It should have been multithreaded (or green threads) with each operation spawning a thread; and then classical read/write locks (with timeouts) on shared state. In some cases where batching happened (for some API calls), some kind of message passing would be needed, but the parent thread would need to block on the thing that does the batch.

timmisiak • yesterday at 4:46 PM

It's non-blocking through the use of stackless futures. The ReplyTo gives you enough to get back to your future, so you can restore your state and continue execution. It might feel like splitting hairs, but it lets you get rid of threads. As for "callback hell", you only get the async/await pattern inside stateless tasks that can send a message back to the parent actor when the task is complete. Then the parent actor can update its own internal state "atomically" with no interruptions.

Is it a panacea? No, certainly not. But I do think it provided some interesting capabilities and tradeoffs that are useful to think about.

dapperdrake • yesterday at 3:56 PM

Fire and forget versus fork and join.

Fire and forget is mostly useless. One of the many counter-examples is the existence of TCP and QUIC. Raw UDP has legitimate use-cases, but falls short for many other real-world use-cases.

01HNNWZ0MV43FF • yesterday at 2:59 PM

> In the simplest form it continues to serve other messages, making the actor reentrant, which can create incredibly surprising scenarios as code executes while you don't expect to changing actor fields in unexpected ways.

That's probably why GUI programming is so hard and every GUI sucks.

Anything that happens outside RAM requires you to respond to every possible input in the middle of any possible operation

➕ show 3 replies