FAQ terminology harmonisation

Peter-Henry Mander erlang@REDACTED
Thu Apr 3 09:05:26 CEST 2003

May I join in?

The hot-swap in Erlang operates differently to shared library reloading 
in one aspect which I think you overlooked: *both* the old and new 
versions of a hot-loaded module will run in a live system *until* all 
the code relying on the module have come to a suitable switching point.

I'll try to explain with an example, a very simple server process that 
runs in a loop receiving and acting on messages (which I didn't compile 
or run, so it may not even work, so spank me :-)


server() ->
   {tagA,Data} ->
     %% do A ...
     server();  % <<<<<<<<<<<<<<<< case A
   {tagB,Data} ->
     %% do B ...
     simple_server:server();  %<<< case B

The difference between cases A and B is that in case B the server code 
will be swapped with a new version if one was loaded at that time 
*without stopping*, whereas case A would continue to use the old version 

I believe that reloading shared libraries will require a fair amount of 
runtime code management programmed by hand, and I'm not sure that loops 
like this one can be swapped without stopping the server momentarily. 
The Erlang version simply never stops, never loses any server state.

I think that the hot-swapping in Erlang is almost (not quite) implicitly 
supported, whereas C/C++ the extra work involved in implementing and 
debugging such a feature just gets in the way of solving more 
interesting problems.


Chris Pressey wrote:
> On Wed, 2 Apr 2003 15:16:42 -0600
> Rick Pettit <rpettit@REDACTED> wrote:
>>On Wed, Apr 02, 2003 at 02:27:34PM -0600, Chris Pressey wrote:
>>>>Well yes, unless the C/C++ application loading the shared object
>>>>(which in turn requires runtime linkage) does so over and over
>>>>again(i.e. loads .so, then later unloads and reloads NEW .so, and
>>>>so on). In this case I don't see the difference.
>>>But how often does this happen in practice?
>>Perhaps not often in other companies, but I have personnally written
>>shared object libraries that are meant to be loaded/unloaded/reloaded
>>as the implementation behind the interface evolves.  Works really
>>well, too, in that C/C++ clients talk to Erlang servers via these
>>shared objects, and as long as the API from C/C++ app to shared object
>>stays the same all sorts of neat changes can take place both on server
>>side (hot code load) and on client side (shared library swap), with NO
> Hey, if it works, more power to you.  I'm still in a position where I'm
> working on projects where a couple of minutes of downtime is acceptable,
> so my experience with hot swapped code comes mostly from playing with it
> - and I don't think I've ever written a .so - so I'm out of my element
> here.
>>My point is that there is NOT a big difference between the two, and
>>that is how Martin should approach the sales pitch with C/C++ guys who
>>argue against hot-code load but are all for shared objects.
> In light of your success with it - yes indeed.
> -Chris

More information about the erlang-questions mailing list