<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 10/11/2012 11:47 AM, Rustom Mody wrote:
<blockquote
cite="mid:CAJ+Teoc_tSrcUXa_VLbQ8476aadWOFxqZZhoxm7NoT7rg=Hbvw@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
<div>On Thu, Oct 11, 2012 at 11:12 PM, Joe Armstrong <span><<a
moz-do-not-send="true" href="mailto:erlang@gmail.com">erlang@gmail.com</a>></span>
wrote:<br>
<blockquote>
I have no idea - you haven't told me what problem you want to
solve -<br>
you've told me the<br>
technique you wish to use to solve the problem.<br>
<br>
This is a bit "back to front" - I'd like to *start* with the
the<br>
problem then figure out how to solve<br>
it - not *start* with the idea that you want FSMs and events
and so on<br>
and not tell me what the<br>
problem is.<br>
</blockquote>
</div>
<br>
Legacy system in C -- Sits on top of an event-oriented middleware.<br>
Since the C system is at core FSM-oriented, it is quite
unstructured (from the normal programming POV)<br>
<br>
Ideally one should throw out the mess and start fresh with an
appropriate technology, perhaps Erlang.<br>
Realistically, the stakeholders always prefer evolution to
revolution.<br>
If not for anything else, just for unraveling the old-code
semantics some re-engineering is inevitably required<br>
<br>
</blockquote>
<br>
There are 4 main ways to integrate Erlang and C/C++ source code:<br>
- NIF<br>
- port driver<br>
- port<br>
- cnode<br>
<br>
The NIF and port driver approach can expose the Erlang VM to any
memory problems the C code creates, though it is the most
efficient. Usually legacy C or C++ code is best integrated with a
port, which is ran as a separate OS process communicating with
pipes. I have an open source project here: <a class="moz-txt-link-freetext" href="http://cloudi.org">http://cloudi.org</a>, which
can simplify this integration and also provide natural scalability
for your legacy source code if: you use the CloudI API (in this
case, in C or C++) to communicate with an Erlang CloudI service that
handles your external communication that needs to scale. Then you
can easily migrate parts of your system, or the whole system, over
to Erlang, which will naturally improve your testing, debugging,
scalability, reliability, concurrency and the source code size. The
integration is similar to integrating with an Erlang port, but it
provides features that prevent integration problems, like:<br>
- stdout/stderr handling<br>
- automatic OS process failure handling (similar to supervisor
restarts)<br>
- request UUIDs<br>
- requests as transactions (i.e., each request receives a response
asynchronously)<br>
- timeouts are enforced for soft-realtime constraints on the
external software<br>
- native language integration (both C and C++ have separate
interfaces which provide the CloudI API)<br>
<br>
As with all open source projects, it needs more documentation, but
tell me if you have any questions.<br>
<br>
<br>
</body>
</html>