[plt-scheme] Re: Thinking in FP vs OOP for large scale apps

From: Gregory Cooper (greg at cs.brown.edu)
Date: Wed May 16 10:34:16 EDT 2007

For what it's worth, both FrTime and Flapjax interact fairly smoothly
with their host languages' object systems.  Our paper from FLOPS '06
tells the story with FrTime:

http://www.cs.brown.edu/people/sk/Publications/Papers/Published/ick-adapt-oo-fwk-frp/

The paper describes a strategy for wrapping sets of classes (in this
case a GUI toolkit) so they can work with signals.  The code is
available in the demos/gui subdirectory of the FrTime collection.  A
similar wrapper (for the HTML document object model) is built directly
into Flapjax.

Flapjax's functional reactive values are actually Javascript objects,
and many dataflow operations exist as prototype methods.  For example,
to make a stream of AJAX requests based on the content of a text box,
we can write code like this:

    var linksInfoE = buildRequest(extractValue_e('userName').
            		           filter_e(nameFilter).
    		                     calm_e(500)).evalForeignScriptVal_e();

This extracts the sequence of values (over time) from the 'userName'
text box, filters out invalid names, and waits until the user stops
typing briefly before making the request.  The result of the
expression is the sequence of responses from the server.  One nice
thing is that method invocations (thanks to the implicit 'this'
parameter) allow us to "pipe together" a sequence of transformations,
much like Unix shell scripting.

Greg

On 5/16/07, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> You may also want to look at the draw.* package that comes with
> ProfessorJ and the (upcoming second volume of How to Design) Classes.
> It is an applicative approach to some GUI programming using classes
> and objects. Because of the implicit 'this' parameter, I consider it
> superior to FRP.
>
> For now just look for teachpacks in Help Desk and follow the HtDC link.
>
> -- Matthias
>
>
>
>
>
>
> On May 16, 2007, at 3:46 AM, YC wrote:
>
> >
> > On 5/15/07, Grant Rettke <grettke at acm.org> wrote: > GUIs are a
> > perfect example to think about using a functional solution.
> > > So, think about it...it would be terrible!!!
> >
> > I think the same, but I just found that there is a style of FP
> > called Functional Reactive Programming that purportedly models GUI
> > more declaratively than OOP's handlers & events.  Flapjax and
> > FrTime are working implementations of FRP.
> >
> > http://citeseer.ist.psu.edu/cooper04frtime.html
> >
> > http://www.flapjax-lang.org/
> >
> > http://www.haskell.org/frp/
> >
> > It seems that I found more links w.r.t to functional style in
> > Haskell on the net maybe due to Haskell being pure functional...
> >
> > Thanks,
> > yinso
> >
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.