Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the actor model limited to specific languages?

I was reading an interesting blog post about Erlang/OTP and the actor model. I also hear that Scala supports the actor model. From the little I gathered so far, the actor model breaks down processing into components that communicate with each other by passing messages. Typically, those processes are immutable.

Are those features language-specific though or more at the architecture level? more specifically, can't you just implement the same actor model in almost any language, and just use some form of message-queue to pass messages between worker processes? (for example, use something like celery). Or is it that those languages like Erlang and Scala simply do this transparently and much faster?

like image 240
gingerlime Avatar asked Apr 25 '12 20:04

gingerlime


3 Answers

Certainly you can define an "Actor Library" in virtually any language, but in Erlang the model is baked-in to the language, and is really the only concurrency model available.

While Scala's actors system is well implemented, at the end of the day, it still vulnerable to some hazards that Erlang is immune from. I'll draw your attention to this paper.

This would be the case for any Actor library implemented in any imperative language that supports shared mutable state.

An interesting exception to this is Nodes.js. Some work is being done with actors between Nodes that probably exhibit the same isolation properties as Erlang, simply because there is no shared mutable state.

like image 189
dsmith Avatar answered Oct 04 '22 02:10

dsmith


Actor model is not limited to any specific platform or programming language, it's just a model after all.

Erlang and Scala have really good and useful implementations of this model, which fits nicely in typical technology stack of these platforms and helps to effectively solve certain kinds of tasks.

like image 31
Ivan Blinkov Avatar answered Oct 04 '22 04:10

Ivan Blinkov


To add to the points mentioned above, the fact that in Erlang actor model is the only way you can program, makes your code scalable from the get-go. Erlang processes are lightweight, and you can spawn 10-100K on one machine (I don't think you can do it with python), this changes the way you approach problems. For example, in our product we parse web server logs with Erlang and spawn an Erlang process to handle each line. That way, if one log line is corrupted, or the process that handles it crashes, nothing happens to the other ones. Another difference is when you start using OTP you get processes supervisors and you can make processes connected so if one terminates all the others do. Other than that, Erlang has some other nice feature (which can be found in other languages through libraries, but again here it's baked in) like pattern matching and hot deploy.

like image 22
talg Avatar answered Oct 04 '22 02:10

talg