Java, JavaScript, PHP, Programming, Ruby
Java 6 and support for dynamic languages
Java SE 6 was released last week. How many of us are now running 2 major versions behind? :)
There are a few goodies in this release, including performance gains and better debugging and monitoring, but the one I’ve been waiting for is JSR 223, explicit support for “scripting” languages. I first got excited about this JSR when it seemed that the reference implementation would be PHP. At the time I did most of my work in PHP, and I was excited about bridging the languages. Instead Java 6 ships with Rhino, a JavaScript interpreter written in Java, but that’s just fine if not better. There’s a longer list at scripting.dev.java.net anyway, including PHP on the JVM.
Why does this matter? I believe that the future of Java is not so much Java-the-language as Java-the-platform. I have felt this from the day I first encountered Jython (four years ago already?). Encounters since then with JRuby, Rhino, and Scala have only made my convictions firmer. Recent actions from Sun (and the JCP) lead me to believe that more than a few people there there recognize that if the JVM is one of Java’s core strengths, then the Java platform has a future somewhat distinct from the language. Sun hired two lead JRuby developers (locals Charles Nutter and Thomas Enebo). With JSR 223 and now JSR 292 (“Supporting Dynamically Typed Languages on the Java Platform”), which I believe we can expect in Java 7, it will be taken a significant step further. As Danny Coward points out in a recent interview, JSR 292 introduces the first bytecode in the JVM that is not used by Java. To me, this is a fairly clear endorsement of non-Java languages as part of a broader Java platform.
Microsoft is doing the same thing, by the way. Sure, much was made of multiple languages running on the .NET Common Language Runtime when it was first announced, but I have the distinct impression that C# is very much the canonical language for .NET development. But a few things have happened in the past year that tell me this is changing: Microsoft hired Jim Hugunin, lead developer of IronPython, a Python implementation for .NET (Hugunin is also the creator of Jython), then released IronPython for ASP.NET They’ve also been working with Zend to make the PHP experience better on IIS, including writing FastCGI for IIS 7.
I’m kind of surprised that I haven’t written about this more here. I think I’ve avoided it because it seems so damn obvious. But it isn’t, not really. It may be obvious within the areas of the blogosphere where I spend time and in the local Ruby community. But in the real world of day-to-day Java development to which I subject myself, in which most are unaware even that Sun has open sourced Java (it’s a culture thing), much less that Java 6 has been released and what it includes, talk of languages other than Java is very strange and uncomfortable news. I still get polite nods and bemused or uncomprehending looks. Daily.
It also occurs to me that there are readers of this blog who do not live immersed in the world of Java and who have valid reasons for being unaware of recent events. :-)
A quick note. I put “scripting” in quotes above because labelling languages like Ruby and Python as “scripting languages” is unfair and indicative of the historically dismissive attitude that some programmers have held toward them. To sound au courant, you should know that the currently favored term is “dynamic” or “dynamically typed” to distinguish them from statically typed, early binding languages like Java. The wrinkle is that in JSR 223, those languages are used for scripting, playing second fiddle to Java. JSR 292 shifts this balance.
So there. Nothing earth-shattering, but now at least maybe you understand why I talk about JRuby a lot.
17 Dec 2006 Sam
I play with Java 5 and Java 6, but still only recommend Java 4.
Why? Because its the most stable.
If Java is to truly be a “platform,” they need to fix some of the stability problems before cramming in new features. Java 5 is still a bit crashy on some systems.
And now with Java 6 and scripting language support? Hoo boy… lemme just say DUCK!
Hi Sam, what do you think are the *real* advantages of having support for dynamic languajes at the server side in the Java Platform?
Thanks
Mauricio
First, in case for some reason it’s not obvious, I should make clear that for application development, especially web apps, I have a strong preference for working with dynamic languages. This is primarily for speed of development and ease of maintenance, but I also often find need for language constructs like closures and continuations that aren’t available in Java (or PHP, for that matter). I am not, however, some anti-Java wank.
That said, I want to write a web application in a language like Ruby, PHP, Groovy, or Scala, and have it connect to back-end services written in Java. This can be done by passing XML back and forth, but there may sometimes be advantages to connecting directly to, say, EJBs. So that’s one advantage: making this sort of interop easier, or at least offering another option to explore.
Tim Bray has demonstrated the usefulness of tapping Java libraries where there are holes or insufficient libraries in Ruby — say, working with XML.
Using something other than XML for configuration is Very Nice Indeed. Why not JavaScript?
Bottom line? I like a lot of tools in my toolbox, using the right language(s) for the job. Sometimes I’m going to need to access what the Java ecosystem can offer, and being able to do that with a non-Java language running in the JVM or having easy hooks to it is one very tempting tidbit.