[plt-scheme] Functional Abstraction in Java

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Wed Jul 1 15:58:24 EDT 2009

Joe Marshall wrote:
> On Wed, Jul 1, 2009 at 11:10 AM, David Van Horn<dvanhorn at ccs.neu.edu> wrote:
>> all of your favorite functional idioms can be expressed in
>> Java, just with considerable notational overhead.  It's fun to try...
> 
> You have a very weird idea of fun.

You sound just like my parole officer.

> semicolons    8
> curlies       8 pairs
> commas        8
> parenthesis  13 pairs
> angles       13 pairs
> 
> public   3
> new      3
> return   3
> apply    7
> IFun1   13
> double   1
> Double  24

Most of this would go away with partial type inference.  But I really 
don't pay it much mind.  There's a significant constant syntactic 
overhead in defining the abstraction, but using it is cheap.  The 
important point is you can still design programs using functional 
abstraction; there's no need to abandon one of your conceptual tools 
just because you move into a Java setting.

David


Posted on the users mailing list.