Do Erlang BEAMS act like Java applet?

Matthias Lang matthias@REDACTED
Fri Sep 13 21:07:12 CEST 2002


Jilani Khaldi writes:

 > Having 2 computers A and B connected to the web and both are 
 > running Erlang. The computer B has somewhere (say in
 > "/usr/physics") an application called "magnetism.beam" which 
 > requires other "*.beam" to run and all these files 
 > are in "/usr/physics". 

 > Is it possible to run "magnetism.beam" on the Computer A 
 > (something like Java applet)? 

Yes.

If A & B share filesystems, such as through NFS, then you don't need
to do anything apart from setting your code path.

If A & B are connected via distributed Erlang (or HTTP, for that
matter), it's reasonably straightforward, albeit fiddly:

    (b@REDACTED)3> {ok, Bin} = rpc:call(a@REDACTED, file, read_file, ["gth_log.beam"]).
    {ok,<<...>>}
    (b@REDACTED)4> code:load_binary(gth_log, "remote_file_gth_log", Bin).
    {module,gth_log}

(I only have one computer here, so my two nodes are on the same host,
but the method is identical for multiple hosts).

 > Is it possible to run it on B and have the output on A (something 
 > like X server)? Or combining both: calculations on B and 
 > visualization on A? 

You can divide your application across nodes any way you want. In
practice you'll be restricted a by what sort of user interface you
want.

There's quite a bit of documentation to help you get started, for
instance the "getting started" guide has a quick introduction to
distributed Erlang:

   http://www.erlang.org/doc/r8b/doc/getting_started/part_frame.html
   
another good source of information is the Erlang book, which you can
download from

   http://www.erlang.org/download/erlang-book-part1.pdf

it's a little out of date, but it's lies are mostly of the omission type.

Matthias



More information about the erlang-questions mailing list