[erlang-questions] cost of integrating 3rd party SW

Vance Shipley vances@REDACTED
Tue May 27 06:27:15 CEST 2008


On Mon, May 26, 2008 at 09:37:52PM +0200, Joe Armstrong wrote:
}      - Do the components run on the same machine?
}      - Is a bug in one component allowed to crash the other component
}      - can we upgrade the components without interrupting the service?

I have used a number of methods to write "drivers" for third party
libraries with C APIs.  First there was the Interface Generator (IG)
which was included in OTP long ago.  Later I used erl_interface and
once ei appeared wrote new drivers with that.  The first linked in
driver I wrote was static but now I write dynamically loadable linked 
in drivers.  Most of these make use of the thread pool.

I never really understood the dire warnings about bugs in the linked
in driver crashing the emulator.  In my systems the driver was an
integral part of the system and if it crashed it was catastrophic so
restarting the emulator was the correct action.  Properly configured
embedded systems handle the recovery.

When using erl_interface/ei the driver is in a seperate OS process
acting as a "C Node" and interfacing using normal Erlang distribution
protocol.  Here if the driver crashes the Erlang code simply sees a
node become unavailable (i.e. {nodedown, Node}).  This behaviour may
well be more appropriate for some applications.  My thinking is that
if I put my efforts into an effecient and  reliable linked in driver
I always have the option of dedicating a node to running the driver
and use it in the same way as as a C Node.  It may be a bit more
heavy weight approach but it has the advantages of being a real node.
A C Node doesn't behave exactly like an Erlang node.

I hear many complaints that writing drivers is hard.  While I did
find it hard the first time I did these things I was coding in C after
all and that is harder than what I've become so used to in Erlang.
The driver_entry callbacks and erl_driver API may take a bit to wrap
your head around however once you have you should find that it has
been made as easy as possible for you.  The emulator handles file
handle events and thread completion for you and you write handlers.

While all too often the first part of my projects are to write C code
just to allow me to write the rest in Erlang I feel it is worth it.

	-Vance



More information about the erlang-questions mailing list