On Thu, 6 Aug 1998, Patrick Logan wrote:
> Regarding the use of JNI (Java Native Interface) to integrate Java and
> Haskell...
>
> Another approach is to use sockets. It is easier to develop, and easier
> to debug. Another advantage is that the sockets can use a
> language-independent protocol, making it suitable for a number of
> languages.
That it true, but it is not really enough. The original servlets
interface for Apache used this approach (C code in apache effectively
proxies requests to the servlet using a proprietary data structure).
However, the servlet implementation on Microsoft IIS, called Java as a DLL
and was much faster.
> For example, in this case the goal is to have a GUI library for
> Haskell that runs on the Java GUI. If a modest "GUI Server" protocol
> is built in Java then Haskell, SML, Scheme, Clean, whatever, can all
> open sockets to the server and create simple GUIs. As the capabilities
> of the GUI Server grow, all the other languages can take advantage of
> it to create more complex GUIs.
We did something like this with Java a while back. We modified an
implementation of TCL written in Java so that one could create java
objects and call java methods from within Java-TCL. We then set up a
server that allowed one to telnet into a jvm and through an
interactive TCL shell manipulate and modify system objects at runtime.
It was slow but it worked (both because reflection is slow and TCL is
slow).
We then wrote client processes that telnetted into the JVM and checked
status or did configuration etc.
The problem with a solution like this, is that you still have to deal with
the issue of marshalling and unmarshalling data accross the connection.
In the end we switched to RMI. If we did it now, we would use XML/RPC.
In either case, speed considerations substantially limit the applicability
of the technique. (As a special case, this system might work reasonably
well for GUIs, but you wouldn't want to use it to access Java's Socket,
HTTP, or Database libraries without a lot of work.)
-Alex-
___________________________________________________________________
S. Alexander Jacobson i2x Media
1-212-697-0184 voice 1-212-697-1427 fax