Why Java remains the most popular language on the JVM

By on May 5, 2008 12:01 am

Mark Ramm-Christensen posed some questions about using the JVM as a platform for dynamic languages. Many people do, in fact, use dynamic languages on the JVM (Groovy, Beanshell, Rhino, Jython, JRuby are some big ones… and don’t forget Scala, Nice and other “non-dynamic” languages that target the JVM). But Java the platform has not gotten widespread or serious attention until recently (witness the recent resurgence of Jython, the rise of JRuby and the coming of the Da Vinci Machine).

Mark cites a blog post by Martin Fowler (Groovy or JRuby), which also talks about the rise of new languages on the JVM:

Until recently the Java cry was One VM and OneLanguage. (As opposed to the CLR which started with the cry of one VM and many languages – providing they’re C# or VB.) This seems to be changing as people realize the limitations of Java and begin to seek out different capabilities.

While leading TurboGears, there were definitely quite a few people that I encountered who migrated to TurboGears on CPython because they were unhappy with Java. Python had a great year in 2007 and is continuing to grow well in 2008.

But, all of that growth in Python and Ruby is hardly making a dent in terms of the number of people programming in Java. Why is that?

My theory is that there are two main reasons:

  1. Java people like static typing, either consciously or unconsciously
  2. Java people like IDEs

I’m leaving out a third reason which is probably the most likely: inertia. For the moment, I’m going to assume that people aren’t sticking with Java because that’s what they’re used to or all they know.

I think that some people believe that static typing provides sufficient automated checks for their software. I can’t deny that static typing will catch typos right away and helps to ensure that some typos don’t make it through if you’ve got less than 100% test coverage. In reality, though, typos are a lot less important than errors in logic or function, which is what you try to catch with unit tests.1

My two guesses as to what Java people like kind of go hand-in-hand. In addition to catching typos, static typing also helps to give IDEs like Eclipse their power. Code completion, automated refactorings, instant feedback on typos and instant jumping to source for different classes are all features that benefit from static typing. Yes, IDEs like Wing, Komodo and Aptana Studio do this for Python, JavaScript and other dynamic languages. But, if you’ve done any serious work in Java, you’ve undoubtedly experienced how much more reliably the IDE performs these functions in statically typed code.2

The fact remains that Java, as a language, makes you deal with many, many more lines of code than a language like Python, Ruby or JavaScript. The difference is not due to static typing. Take a look at Scala if you don’t believe me. The difference in lines of code and amount of “noise” on each line of is really due to Java’s lack of good property handling, operator overloading, functions as first class objects, etc.

Oliver Steele made an interesting distinction between being language oriented and being tool oriented. As he points out there, a language would ideally appeal to both types of programmers and will eventually do so if it matures to the point where it gets good tool support.

So maybe Java users are in a spot where they’d like to use a different language to gain the extra mental bandwidth you get through cleaner, more concise code, but they also want their static typing and IDEs. Today, Scala is not a bad choice, but the tool support is still a work-in-progress and some of Scala’s syntax might be more of a leap than many Java programmers want to make.

There is also a new choice on the horizon: ECMAScript 4 (aka JavaScript 2). ES4 offers classes, which will make many people a lot more comfortable with OO programming in JavaScript. It also offers optional static typing. People who love static typing can still have it. In fact, there are even proposed mechanisms to add type information to otherwise untyped data.

My guess is that people will start moving away from Java (the language) in larger numbers once a new language choice appears that:

  1. Has static typing
  2. Has good IDE support
  3. Allows them to use their existing code

Scala has a shot, but I expect ES4 to come on fast once the Rhino implementation for the JVM arrives.


Notes:

1. In a recent interview, Donald Knuth said he doesn’t like unit tests. Note his alternative, though: literate programming. Test driven development is often viewed as a design technique and not a testing technique, and I think literate programming could be viewed as a design technique as well. Both test driven development and literate programming offer advantages over trusting that static type checks in your compiler will keep you from harm’s way.

2. Smalltalk programmers can legitimately claim that you don’t need static typing to make powerful IDEs. Smalltlak provides its powerful capabilities by integrating the development environment with the runtime environment. This gives Smalltalk the ability to perform completion and refactorings based on the objects in the running system, rather than what the programmer has explicitly stated in source code form. It’s a powerful model, to be sure, but it’s a big leap from the “source code in files” models that people are used to.

Though Smalltalk has been around for decades and has failed to become mainstream, many good ideas from Smalltalk have made it into other systems and I wouldn’t rule out a dynamic IDE+runtime becoming popular in the future.

Comments

  • Pingback: Blue Sky On Mars » Why Java remains the most popular language on the JVM()

  • Marcus

    I think you should consider another explanation, because its the one for me: Ruby, Python, et al just aren’t that much “better” and when you couple that with their fairly obvious warts it doesn’t make a compelling case.

    This is not a troll, and neither am I on some faux “side” of the debate. I am expert with Java and Perl, and have spent my fair share of time in Ruby, C, and plenty more. These options just aren’t compelling enough to someone already very productive in Java. They are great for me in addition to Java, but they won’t replace it.

    Secondly, I think you should also consider that a career coder, even one frequently labeled “Senior”, who started their very first coding in university and who doesn’t have love of the game side projects going on just isn’t that great a candidate for script-like languages with more dynamic features. For those people Java is also an excellent option simply because dynamic languages give them way too much rope.

    I’m not one for dumbing down languages, and I think that Java should have more functional features & syntax sugar, but Java happens to be pretty successful at reducing the crap quotient from the hordes of CS degree holders who really should have stayed in engineering (now that last line was a gentle troll, intended to be taken with a wink and a smile).

  • Ted

    Kevin, don’t forget Static Analysis tools like FindBugs. It helps a lot!

    I use Python, Ruby, C and Java. The only problem I have with Java is the people that use it, not the language itself.

    Big companies are throwing buzzword names around Java such as “Agile”, “Easily adapt to changes”, “TDD”, “BDD”, “Continuus Integration”, “Enterprise”, “Managed Sessions Beans Factory”, “Layered Architecture”, bla bla bla.

    As a result, we have tons of Architecture wannabes and Architecture Astronauts that over complicated simple tasks. Instead of being pragmatic and solve the damn problem these people tend to grab GoF (and other similar design pattern, architectural) book and try to push that circle to a square hole.

  • Hi kevin,
    Nice tutorial.
    Similar tutorial on JVM: Java Virtual Machine, An inside story..
    Do post tutorials frequently.. Waiting to see more..