TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Concurrency in Erlang & Scala: The Actor Model

33 pointsby motterover 13 years ago

3 comments

masklinnover 13 years ago
&#62; A reply() construct is not present in Erlang, where you are forced to include the sender each time you want to be able to receive replies. This is not a bad thing however: Scala messages always carry the identity of the sender with them to enable this functionality. This causes a tiny bit of extra overhead, which might be too much in performance critical applications.<p>An other nice result of Erlang's way (which I'm not sure can be replicated in reply-based Scala interactions) is that the message can be bounced around privately between processes until the final reply is sent (just forward a possibly transformed message <i>with the same contained PID</i> to the next guy in the chain)<p>While this could be done by having the initial receiver act as a middleman, it also means either that middleman has to be blocked until it can craft the final reply or it has to keep a bunch of state around (for each message it received) in order to correctly act on reply information. This lowers its throughput (and may even deadlock it for the former case) and increases its memory requirements. Erlang's way also makes it much easier to spin new processes to handle each message.
jlouisover 13 years ago
The article doesn't use the OTP libraries in Erlang unfortunately. This means that you have a view of low-level Erlang message passing, but most - proper - Erlang programs will process messaging at a much higher abstraction.<p>The most important omission in the example is to monitor processes. If an error occurs in another process while it is processing for a client should have the client knowing about that problem. Otherwise you are facing either a dead-lock situation or a timeout condition which you have to wait until triggers.<p>In other words: Real Erlang programming is not like this.
评论 #3586641 未加载
ramsesover 13 years ago
For those stuck in Java hell: <a href="http://akka.io/" rel="nofollow">http://akka.io/</a><p>It expands upon Scala actors—supposedly will replace them—and provides a native API for Java.