I like a lot the thread architecture of Erlang (small cheap threads and the “share nothing” arhitecture), but it seems that Erlang is not perfectly suited for my application (these things would be more performant in C/C++, while Erlang is not best at that).
Well, as I already said, I REALLY like the thread architecture of Erlang (which isn’t using OS threads). So, my question is – is there any similar library which implements this architecture for usage in C/C++ code? As far as I’ve googles, couldn’t find anything better than “green threads” of Java (deprecated a long time ago and removed from current versions) and “fibers” of D (limited to one “real” thread, while Erlang threads are executed by Erlang on the most suitable “real” thread), which are somewhat similar, but not as powerful as Erlang threads.
If there is no such library, I am considering using the erl_nif interface for writing the needed chunks of code in C/C++. But I couldn’t find anywhere any performance analysis – is erl_nif is fast, or the overhead of “transforming” the Erlang terms/datatypes into C/C++ types is really big?
Thanks!
Akka offers Erlang style actors but for Java/Scala, not C/C++.
From what I’ve read (e.g. http://www.scribd.com/doc/87376094/Erlang-and-OTP-in-Action#outer_page_324), NIFs are fast but potentially dangerous in that they can crash your whole Erlang program. You could try using Erlang ports (http://www.erlang.org/doc/reference_manual/ports.html) to communicate with C/C++, which is safer as the port keeps the non-Erlang code separate from the Erlang supervision tree.