Wednesday, February 4, 2009

Poor mans lambdas

A lot of my recent work has been in scala (I try to do any "green fields" work now in scala) so closures/lambdas are very pretty and flow freely in scala.

I did however read with interest about "lambda4jdt" a way of making code in java "look like" it is using a real lambda, but only really as a UI trick in eclipse. Interestingly I recall Cedric Beust talking about this previously (that is, the idea that IDEs can change the appearance of code from the underlying character stream).

Lambda 4JDT
:

So screw the dead JLS (Java Language Spec), just go an add it in as low cal eye candy ! I like it !
With some excitement I went to IntelliJ's bug tracker to put in a similar feature request (I always struggled to explain what sort of "code folding" I wanted). I found out in a matter of minutes the feature is coming in IDEA 9 ! Nice !

In early versions, they used an actual lambda character:


(apparently it won't be exactly like that in the final version).

In any case I prefer scala in almost all ways, but for existing/legacy code, nice to have smart IDEs to present things as they should be.