[Prev][Next][Index][Thread]

Distributed higher-order functions



This is a follow-on to my questions about distributed objects
vs. generic functions.  The next several paragraphs summarize what I
learned so that I can ask the questions at the very end of the message.

It now seems that systems like EJB address two distinct things:
 - Distribution of objects
 - "Packaging" of the functions you can call on the objects
These are conflated in Java/EJB (which is what got me started on this)
because Java classes conflate the concepts.

Java/EJB uses EJB classes in both ways: "entity beans" are the
persistent objects (but also exist for their packaging), and "session
beans" (that exist only for their packaging).  Interestingly, EJB has
two kinds of session beans:
 - Stateless
 - Stateful, in which state can persist across multiple calls to
   functions in the bean

Now that I roughly understand EJB, I am dissatisfied with the solution
because it seems to "imperative" and "side- effecty".  For example, if
you have some "business logic" that needs to compute the average price
of some stuff (which stuff is provided by a bean class written by
someone else), you have to get all of the objects, ship `em over the
next, just so you can sum the prices.  OK, that's not side-effecty, but
I would sure rather be able to ship
 #'(lambda (coll) (reduce #'+ coll :key #'price :initial-value 0))
to a 'do-things' method on my bean class, and have the work done
entirely in the bean without have to marshall up and move 132,454 prices
over my network.

Some people chimed in with the idea of distributing generic functions
(but note that I think that misses the packaging up of functionality
provided by class-based distribution).  Someone else pointed me a Java
Spaces, which are an extension of the Linda ideas, which I knew nothing
about until 5 days ago.  Thanks for these pointers; they were fruitful,
tho' I haven't yet got my head around Linda and Java Spaces completely.

With all the above in mind, I had a small realization:
 - An entity bean really is a distributed instance of a user class that
   provides (or can provide) persistence (i.e., storage in a database)
   and packaging for a bunch of methods on the object.  The EJB notion
   of this is adequate, but something like Lisp or Dylan needs a way to
   provide the packaging.  Sufficient macrology will probably do the
   trick, but I think the people who think this is easy are in for a
   rude surprise.
 - A stateless session bean is a package of related functions that are
   operating in an empty environment.
 - A stateful session bean is a package of related functions that are
   operating in a non-empty empty environment.

Perhaps the session beans can be implemented as a bunch internal
functions within a single top-level function (tho' there is the little
problem that in Lisp/Dylan, internal functions don't do dispatch...)?

At long last, here are my questions.
 - Is anyone aware of any work on distributed higher-order functions?
   (That 'reduce' example above is my motivation.)
 - Has anyone addressed the efficiency issues?
 - Just how hard is it to host Lisp or Dylan on the JVM?  Are there
   small semantic changes to the languages that would make this much
   easier?  What about the new Microsoft VM?

Thanks for your forbearance...