About Java, closures and attracting new developers

Julian Exenberger has an interesting post where he states that of the top 10 languages on the Tiobe index, Java is the only one not to support closures in any way, either officially or by at least som kind of (planned) support. He goes on to state that Java is going to be perceived to be obsolete, and it's going to be a harder sell in the enterprise because of this.
Another possible explanation
It might be that the Java crowd is panicing about the wrong thing. Surely, Java.next, as Stuart Halloway describes in his article Java.next: Common Ground might turn out to increase productivity a lot, but I guess language features are not the reason why some1 developers are leaving Java for Ruby or less known languages. I guess the reason why Ruby got popular is because of Rails2. Sure, the Rails people argues that it's better because of things like "metaprogramming", dsl's etc., but then, why is it possible to make an equally good, if not better, web framework in PHP? And why is everyone still talking about Ruby, and not about Django, TurboGears, symfony?

Here is what I guess: It's because of the enthusiasm in the Ruby camp. They're not very many, but they have a good language, they innovate, and they make a lot of noise! What Java lacks most is enthusiasm. Innovation can be copied (it's mostly open source), and lack of language featueres can be programmed around3, but not without enthusiasm, that is not going to happen. 

Of course there used to be a couple of reasons for that lack of enthusiasm, but they're starting to really fade away. Here are some examples: 
Focus on strength

Java has some unique features that makes it stand out. If we want Java to succeed, advocates of the language should focus on things like:
  • Supported by multiple big companies.
  • Secure. Java is widely perceived as a very secure programming language.
  • A clean language.4
  • Very good ide and debugging support.
  • Both Ruby, python and PHP are available on top of the Java platform, together with some Java-only languages like clojure, scala and groovy.
I have left out the open source argument, and the multi platform argument, because both of these holds true for both Ruby, python and PHP.

Java isn't dead, and it doesn't need to die even if Sun doesn't add all those cool features people are asking for. Start beeing enthusiastic!

1: Yes, I'm not writing many. Most of us still use Java, and it even seems that more people are still searching for java programming than for ruby programming: http://www.google.com/trends?q=java+programming%2C+ruby+programming
2: I guess this is evidence enough: http://www.google.com/trends?q=ruby+programming&ctab=0&geo=all&date=all&sort=0

3:  Yes, I am talking about my favourite web framework, symfony. Programmed in php, which, in case you didn't know has no closures (yet), and is not elegant at all, but rather ugly. I mean, having to prefix variables with $, and using "->;" instead of "." is just ugly. But that doesn't prevent sensiolabs from creating a super effective web framework out of it, and it has not prevented yahoo from choosing it over rails for both the new delicious site and yahoo answers.
4: I sometimes spend some hours maintaining Delphi code, and there is a couple of features that I really dont like, like the "with" keyword, that saved the previous author from some typing at the cost of making that hundred lines function even more unreadable, and the possibility to mix two different classes in one unit, and even mix the implementations!


  1. You guys, missing the point: there is already some specs and buzz around closures in java7.


  2. Java has plenty of buzz. What it lacks is critical features like closures. Once you've used closures a lot in another language using Java is so painful.

    Gafter's and Gosling's ideas need to be implemented as soon as possible. (I do not like the other two specs, which are very limited and not well thought out.)

  3. If the problem with Java is the lack of closures, then why do symfony (written in php, without closures) rock?

    Java isn't perfect. And I guess that could be the topic for my next post, but obviously you can make an awesome web framework with a not so elegant language.

  4. Java has inner classes, these have many advantages over closures. Like, inheritance, partial implementation, fields, multiple methods, recursive methods, etc. They do have a couple of limitations, no write to locals and probably the big one, long syntax.

    I think that a better option than closures is improved inner classes.