Top five scripting languages on the JVM
Anyone who has followed software development tools during the last decade knows that the term "Java" refers to a pair of technologies: the Java programming language and the Java Virtual Machine (JVM). The Java language is compiled into bytecodes that run on the JVM. Through this design, Java delivers its vaunted portability.
The language and the JVM, however, have been increasingly moving in opposite directions. The language has grown more complex, while the JVM has become one of the fastest and most efficient execution platforms available. On many benchmarks, Java equals the performance of binary code generated by compiled languages such as C and C++. The increasing complexity of the language and the remarkable performance, portability, and scalability of the JVM have created an opening for a new generation of programming languages. These languages lack Java's syntax overload (often referred to disparagingly as its "ceremony") -- that is, the amount of excess code that needs to be cranked out before the code that does the actual work can be written -- but take advantage of the JVM.
[ Eclipse PDT, NetBeans, NuSphere PhpED, and Zend Studio lead a capable field of IDEs for Web developers. See "InfoWorld review: Eight PHP power tools" | With WYSIWYG prototyping environments and preconfigured graphical components, rapid Web development tools can help you build applications faster -- but with less flexibility. See "InfoWorld review: Tools for rapid Web development" ]
In this article, I examine a handful of these languages, comparing and contrasting them, and identifying the needs they satisfy particularly well. I limit myself to the JVM languages that are free and open source. The closed source, commercial world, surprisingly, has few comparable offerings. The one standout is Cold Fusion Markup Language, which is part of Adobe's Cold Fusion Web application development environment.
Technologists differ on what exactly is a scripting language. In its narrowest definition, it's a language that enables the developer to write quick programs. These programs are generally interpreted or semicompiled, rather than compiled in the traditional manner. In choosing the languages for this review, I used a broader definition, which is any JVM language that is simpler to code in than Java. Some are compiled, others are semicompiled, but all are suitable for rapid development. The languages I've focused on are Groovy, JRuby, Fantom, Jython, and Scala. There are a few other candidates, namely Clojure, JavaFX, and NetRexx, which I cover briefly at the end.
The JVM scripting languages today naturally divide into two groups based on their rate of adoption. Groovy and JRuby fall into the popular camp, while the others are niche players -- that is, they appeal to a small community at present. It's important to note, however, that both Groovy and JRuby were also niche players two years ago, so there is no reason to believe that a niche language is relegated permanently to the margins. I believe that the likelihood of emergence favors Scala, then Fantom, and finally Jython. As I explain later, I think Jython's moment in the sun has probably come and gone.
JVM scripting language No. 1: Groovy -- powerful, high-level, enterprise-friendlyJVM scripting language No. 2: JRuby -- a better Ruby than Ruby?JVM scripting language No. 3: Scala -- fast, multiparadigm programmingJVM scripting language No. 4: Fantom -- Java and .Net plus performanceJVM scripting language No. 5: Jython -- Python for the JVM Clojure, JavaFX, and NetRexx
JVM scripting language No. 2: JRuby -- a better Ruby than Ruby? JRuby is a Java port of the Ruby language. Ruby itself is a scripting language developed in the mid-1990s in Japan, where it has enjoyed wide adoption. The language was a sleeper in the United States and Europe until its killer app, Ruby on Rails, was released in 2004. Using a set of conventions that made assembling the various parts of Web applications much easier, Rails was quickly put to use in developing websites for small and medium-sized businesses. The popularity of Rails led to an explosion of interest in Ruby.
The Ruby language has many of the features I've described in Groovy, but it uses a terser syntax -- allowing developers to get more work done per line of code written. The big problem Ruby faced was performance. In multiple benchmarks, it came in last or close to last when compared with all other languages. This spurred numerous competing projects to rewrite Ruby. Of these, the most successful has been JRuby.
The JRuby project was started in 2001 as a straight port of Ruby code. By 2007, the project -- now under the control of a pair of engineers at Sun, Charles Nutter and Thomas Enebo -- could run Ruby on Rails and delivered performance comparable to non-Java Ruby. Since then, the developers have moved to Engine Yard, a commercial host for Ruby on Rails, where work on JRuby has continued apace. In the meantime, Ruby released the much faster 1.9 version. According to Nutter, JRuby's performance is now comparable with this release.
Like Ruby, JRuby is attractive to developers for more than its very high-level syntax. It also enjoys a pure object-oriented implementation (unlike Java, where some entities are objects and others are not), closures, duck typing, and an interpreter. The use of an interpreter means that you can move from coding to execution immediately. What JRuby has that Ruby lacks are the vast libraries of the Java platform. Ruby has many good libraries, but they are neither as numerous nor as widely used as the standard Java libraries.
The access to Java's runtime environment and libraries is a crucial aspect in determining JRuby's future. Ruby has not broken into the enterprise in a big way. JRuby may well be its ticket there. JRuby has the advantage that enterprises are already comfortable running apps on the JVM, whereas the native Ruby virtual machine is an unknown element whose peculiarities are not known to stokers in the data center. In addition, because of the integration with Java apps, companies can adopt Ruby via JRuby and still leverage previous investment in Java software.
Whether enterprises will favor Groovy or JRuby depends entirely on the needs felt inside the IT development center. Both solutions work well, are supported by paid developers (rather than by volunteers), have growing support among tool vendors, and are likely to be around for a while, delivering working code quickly.
Niche languages The following three languages are not as established as Groovy and JRuby, but they have the elements that could bring them success in the next few years. Even if they don't reach that level, they have enthusiastic supporters who are likely to keep the languages alive in diverse programming niches.
JVM scripting language No. 4: Fantom -- Java and .Net plus performance Fantom (formerly called Fan) is unique among the languages discussed here in that it generates bytecode at runtime for either the JVM or Microsoft's .Net platform. The language is object-oriented with many of the same features described previously for Groovy and JRuby, except that integration with the Java libraries is not as seamless: A special interface is required to interact with existing Java bytecode. Fantom makes up for this shortcoming in part by having extensive libraries of its own.