I was searching about process model of Erlang over internet and found out some graphs slides 3-4 in one of the talk given by Joe Armstrong. They shows a lot of difference between process creation and message passing time between Erlang , java and C#. Can anybody tell me the reason behind such big difference?

- 706
- 7
- 24
-
The graph and the slides yield to little information to know what was actually measured here. It is not even clear what is considered to be a "process". For example, it looks like an Erlang process is not an OS-level process where a Java or C# one is. It seems like comparing apples and oranges... – Dirk Vollmar Aug 24 '10 at 13:40
-
3@0xA3: Erlang processes behaves like processes form developer point of view. They are isolated unit of execution. They behaves like processes, not like threads. It's others fault that they using OS-level processes or threads and don't provide same useful tool for solving real problems. If you want do same things as in Erlang in those languages you have to use what you can so comparison is correct. – Hynek -Pichi- Vychodil Aug 24 '10 at 15:12
-
possible duplicate of [Technically why is processes in Erlang more efficient than OS threads?](http://stackoverflow.com/questions/2708033/technically-why-is-processes-in-erlang-more-efficient-than-os-threads) – Christian Aug 25 '10 at 08:55
2 Answers
In Erlang, processes are not real processes. They are light structures handled by the language. Message passing is also handled by the language, using shared memory when possible.
In the other hand, other languages are using real threads / processes since they don't have built-in light structures like this. Therefore, these structure are a bit heavier, are using thread primitives to communicate (slower).
I don't know about your graph, but I guess it shows that Erlang's processes are better. It's done comparing things that are inherently different, however it show that Erlang rocks to model standalone objects communicating using messages (things you cannot really do in other languages).

- 17,233
- 6
- 44
- 63
-
5I wouldn't say that it uses shared memory, since data is (almost) always copied between processes' heaps. Though still everything happens inside one OS process. – gleber Aug 24 '10 at 14:32
-
1I think Scharron meant that while, conceptually, nothing's shared, it's possible for the VM to share data by passing pointers around rather than copying the data, as an optimisation. – Frank Shearar Aug 27 '10 at 14:15
Erlang processes are very light weight. An implementation does not even need to allocate an OS thread to an Erlang process. This has to do with the functional nature of Erlang.
-
1Not really related to Erlang being a functional language at all. Any language with cheap processes and message passing would do. (Not that there are any other languages with Erlang-like processes...) – Daniel Luna Aug 25 '10 at 14:26
-
1Actually it's very related to Erlang being a functional language in that the the functional nature of single-assignment variables removes much of the burden of process isolation because there can be no shared update or access contention to worry about. Add message copying instead of referencing and you've got a recipe for really lightweight processes. – Alan Aug 28 '10 at 04:24
-