Also on twitter ( twitter.com/nutrun )

Java ain’t no Ruby

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.

7 Responses to “Java ain’t no Ruby”

  1. Ivan Says:

    Which Java are you talking about? I don’t see a Java losing momentum on Dice.com. Just do a search for Java vs. Php vs. Ruby.

    Java wants to be Ruby like Film Making wants to be Flash Banners.

    If you’re trying to avoid flames, you should avoid the flame bait.

  2. Zach Says:

    Closures and continuations were not first introduced into the software landscape in Ruby, but Scheme and Lisp respectively (source wikipedia). In addition, your higher java concerns like IDE defaults and pattern adoption in my mind shouldn’t be what Sun and JCP members should be focused on – I hope they continue to focus on the language itself. There’s room in software development world for both Ruby and Java – really, there is. They both have their pros and cons, as you allude to.

    Now, I have a question for you – can you distinguish whether it is Ruby that is so great, or ROR, or dynamic language based web applications (like django, turbo gears, etc)? Can you make a somewhat objective analysis of when one of these solutions is better for enterprise developers than say Seam or Rife? Comparing the latest in dynamic language web development is only fair if you compare the latest in java web development.

  3. Josh Charles Says:

    Zach,

    I don’t think the poster was claiming that Ruby invented those things. I think the claim was that Ruby has rejuvinated interest in dynamic languages in general, and I can really see that.

    I can’t really say much about Java specifically. I will say that focus on more than the language, inlcuding how that language is going to be used is essential. How can you build something and ignore how it’s going to be used?

    That attitude represents something very very wrong.

  4. Cardsharp Says:

    There is a VERY good reason Java has become more complicated and unapproachable. Actually, there are two very good reasons, but the first is because it is a mature platform that can be applied to any general problem domain, not just Web development. As general purpose platforms mature they add features and become incrementally less approachable. That’s just progress folks. Find me a platform that hasn’t done that. C++ anyone? If java were just a Web development platform like Rails is, it could be kept tight, focused, simple and approachable.

    The second good reason is the Open Source movement itself. Java’s blessing of a plethora of free and open third party libraries is also its curse. It is simply impossible to decide on which Java stack to use. Take Web frameworks as an example – there are already at least 50 and seems like there’s a new one every day. And that’s just web frameworks. If there were a central authority (Rails) dictating how all Web, Middleware, and Persistence frameworks would work, life would me much simpler. But it would also lack the tremendous choice that exists as well.

    Mark my words, if and when the Ruby and RoR products mature, they will also become complicated and unapproachable. It’s just the way of things in our business.

    http://jroller.com/page/cardsharp?entry=apples_to_oranges

  5. chuck Says:

    “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?”

    Because far too many Java developers don’t properly understand package level access or packaged in general? Because if they took a typical university CS curriculum over the last several years, they were taught Java in CS I where they were basically told that if they din’t put “public” or “private” in front of their class declaration, it defaults to “some weird thing you don’t understand, but that maybe we’ll get around to teaching one of these days if you’re lucky.”

  6. unknown Says:

    Just like chuck said, the problem with programming is not the language, but the programmers. Frameworks make it easier, but some developers take it as it is and dont even care about knowing how it works. That gives us typing professionals, not programmers (nor computer scientists, if i may be so bold to say it).

    Java and Ruby solve different problems. Ruby may solve some problems better, but Java also acomplishes that in some others.

    Java may have grown overly complex and fat (yeah, its not all wonders, there are problems with it). Ruby, however, isnt the end-all language, not even the “end-Java” language.

    I’m not qualified to talk about web development, but i figure Rails does a better job (faster, lighter) than Java in many cases. But Java still got more grounds and “confidence” than RoR.

    Ruby ain’t no Java either. And no, i’m not a Java fanboy.

  7. alee Says:

    I am also a java programmer, currently working on web projects and its the fact that Java is becoming more and more complex.

    Before writing a project you have to decide which framework to follow. Just imagine if you have to create a Struts application without a well managed IDE, it’ll be a hell of difficult things to manage all those XML files and descripters.

    The same thing can be done easily on .NET or PHP.

    EveryDay, Java is becoming more secure or more paternized but making the life of programmers a hell of difficult.