Closures march on toward mainstream


Functional programming is the conflation of several interesting and useful ideas, but to me, the big lesson mainstream programmers need to (and can fairly easily) learn from FP is closures. Closures have been around approximately forever and their merits are unquestioned among programming language geeks and Comp Sci nerds, but the proverbial “average programmer” still has no idea what they are.

But over the last couple of years, closures have finally broken out of the ivory tower. The emergence of AJAX as a sexy new programming discipline has a generation of web programmers pushing JavaScript to its limits, and JavaScript–for all its foibles–offers full-fledged closures. Rails catapulted Ruby into the collective consciousness of hipster programmers, and Ruby is just dripping with closures (aka blocks). C# 2.0 introduced anonymous functions which are closures (very cleverly implemented ones at that) and C# 3.0 greatly improves the syntax and puts them front and center with LINQ.

And now, Java–yes, that Java!!might get closures as well! It’s only a “proposal” at this point, but the authors are all heavy hitters: Gilad Bracha (co-wrote the JLS), Neal Gafter (father of javac), James Gosling (father of Java), Peter von der Ahé (currently works on javac).

Closures in Java… wow. It doesn’t get any more mainstream than that. Perhaps closures will be taught in introductory Java courses. The thought of it makes me smile.

%d bloggers like this: