So, Closures in Java, huh? Too little, too late, or just too late?
Before we get into arguments, I’d like to make myself clear to both camps…
Firstly, I like Ruby. At the moment, I like Ruby more than Java. I also like Lisp more than Ruby. I am also less competent in Ruby than I am in Java and I am even less up to speed with Lisp. So I am not trying to prove which one is better because I recognize I am not qualified enough to make this kind of judgment.
The web is full of praise and reasons as to why one should pick up Ruby, so I’m not going to preach Ruby here, but I have to admit I agree with most of the things the rEvangelists go on about. I’m probably one of them, come to think of it, although you won’t catch me admitting it in public….
There are a few things that make me skeptical about the whole Dynamic Language explosion.
At the moment, I can identify two reasons in relation to Ruby’s popularity.
The first one is obvious. Ruby on Rails. Ruby only properly appeared on the map post-Rails, something especially interesting, if we consider that Ruby has actually been around longer than Java. And Rails not only ignited interest in Ruby, but also revitalized the flames of languages like Python, SmallTalk, etc. This begs the following question: Is it Ruby that’s really this good, or is it actually Ruby on Rails?
The second reason has its roots in the first one. Rails came along and reminded developers that things don’t have to be that complicated. Given our inquisitive nature, us developers will always dive head first into new paths of knowledge and understanding. Undeniably, The Enterprise has stagnated Java to a level that many of us were just begging for something new to learn and explore. Rails hit the perfect combination of inventiveness and timing.
I am wondering, however, given Ruby’s less challenging (it is simpler) nature, is it going to stick around long enough, or is it going to be forgotten as Ruby related challenges become comprehended and conquered? I doubt this is going to be the case, mostly because of the sheer pleasure every developer I know who’s actually devoted some time into it experiences by developing in it.
One great achievement the Dynamic Language wave has managed is opening the eyes of Enterprise (ahem…) developers to Dynamic ways. Especially during the last 12 months, many Java coders, including myself, have attempted porting Ruby/RoR features to Java. And now, there’s a formal proposal for Closures and Local Functions in Java. The word function was OO blasphemy in Java circles not so long ago, by the way…
Then, of course, there’s Rife and its Continuations and Groovy and others, I’m sure you read about them all the time. I don’t mean to sound harsh, but I can’t come up with many examples of followers who tried to copy a leader ever becoming the leader themselves. If I want Ruby functionality, I might as well code in Ruby. I have tried and enjoy the aforementioned attempts very much, it’s just that I get the impression they’re trying to cover holes, not break new ground.
More importantly, at the moment, Closures and Continuations are the least of my worries when it comes to Java, which is the language I spend most of my time in, whether I like it or not.
I would definitely like to see them in Java 1.7, earlier would be even better. But before that I’d like more important issues to be addressed.
Issues like the growing trend towards every Class having a corresponding Interface. Like how most developers are completely ignoring Package level access. Seriously, IntelliJ IDEA by default puts public in front of every new Java Class. Why is that? All methods that are not private are public, when clearly, nobody outside their package should be accessing most of them. Why doesn’t anybody mention Component Oriented Design any more? Is it because it doesn’t do AJAX blink in one line of code?
The reason Java is losing momentum is because it is becoming (has become?) overly complicated. For no good reason, either.
I’d like to see focus shifted to the core characteristics of Java that made it such an interesting prospect at first, and these, in my opinion, boil down to good software design, powered by fundamental OO principles, not bells and whistles like Continuations, which, according to the Ruby FAQ, can be used to implement complex control structures, but are typically more useful as ways of confusing people.