The buzz of closures
I found an interesting discussion about closures. I find this quote particularly true (and amusing):
There has been a great deal of interest in closures lately, driven in great part by the fact that there is talk of adding some form of anonymous functions to the Java. Most of the time, people talk about “adding closures” to Java, and that prompts a flurry of questions of the form “what is a closure and why should I care?”
Yes, why would they care? As someone put it, if you always programmed in Basic, you think you don't need recursion. You can't comprehend a complex language feature—such as recursion—unless you actually try to make some sense of it. Yes, no matter how many computer science courses you'd take, you can't do real programming unless, well, you do real programming. In other words, your teacher might have told you what recursion means, but unless you actually use it, you'll never know what is it good for.
Consequently, I think there are 2 types of programmers.
Some would spend a lot of their free time trying to understand and make use of some techniques that might—or might not, but usually will—serve them for real-world problems.
The other camp is very boring: those are the people that are payed for some job and only do what their boss asks.
Now, the boss will never ask you to use closures (or any other language feature for that matter). He'll just tell you “do this” ASAP, and you have to figure out how to finish it as soon as possible. Well, using closures, ASAP can mean a lot sooner than without them, no matter what language are you programming in (assuming of course that it supports this 30-years-old concept; some new and much hyped languages still don't.).
I have former colleagues that have completed their B.S. in computer science (which I still didn't). One of the courses you do in the college is an AI course which, of course, uses Lisp as the supporting language. Well, the horror is that none of them understands what's a closure, and asks me every time I mention the word “OK, Java/C# might not have that, but why would I need it anyway?”.
So after preaching functional programming for some time, and after I saw my fellows here ignore me, I've come to the conclusion that it's better for them not to understand it. A boss is a boss, and he'll favor someone who has a B.S. (which I don't). So I at least want to keep the technical advantage. :-p
So, ya Java folks, don't even think about closures. You don't need them. Just focus on writing specs and UML-s and Factories and Managers and Listeners and Executors.