[<<][compsci][>>][..]
Tue Jan 5 10:45:52 CET 2010

Java and CPS vs callbacks.

I'm working on Android lately, which has a lot of asynchronous message
passing going on.  Using this without anonymous classes is a pain: the
alternative is to extend the calling class with callbacks implementing
a particular callback interface.

It's much easier to use anonymous objects.  This is essentially CPS:
call a function, and provide a context it needs to invoke whenever it
sends it reply.

What this really shows me is the arbitraryness of designing with
objects and classes.  I think I understand why ``patterns'' are so big
in OO: they are essentially an informally specified set of rules to
adhere to to not get bogged down in mind numbing low-level decisions.

However, the patterns are in the design doc, not in the source code,
and the programmer is supposed to recognize them, looking past the
boilerplate code.

In Functional programming this is less so.  It seems that it's easier
to abstract away boiler plate code: just add yet another higher order
function.



[Reply][About]
[<<][compsci][>>][..]