ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Technologies to Watch: A Look at Four That May Challenge Java’s Development Dominance

by , author of Beyond Java

Bruce Tate has an amazing track record when it comes to identifying successful technologies. He was one of the early developers that identified the emergence of the Spring framework; he predicted the demise of EJB 2 technologies a full year before the EJB 3 expert group abandoned the older approaches. In his new book Beyond Java, Bruce looks at languages and technologies that may challenge Java's dominance in some development niches. In this article, Bruce covers four important emerging technologies.

Java has been an outstanding development language for the industry because it's brought a remarkable unity and attention to important standards where practically none existed before. But like all programming languages, Java will too fade in time. As I did my research for Beyond Java, one recurring theme was that a growing number of people just don't believe Java is productive enough anymore. This set of technologies can help make you much more productive. They're not suitable for every project, but they are excellent tools when applied to the right problem.

1. Dynamic Languages

Dynamic languages can be much more productive than static ones like C++ or Java. They allow you to express more with less. Here, I'll focus on Ruby, the hottest emerging dynamic language right now. Compare "Hello, World" in Ruby versus Java:

puts "Hello, world."

It's simple and concise. You don't have to write anything beyond the code that does the job. And the Java counterpart:

class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello World!")

With Java, types are static. That means the compiler checks all types; you must create and compile a full program. With Ruby, types are dynamic, so you don't have to declare them. You can just start typing and go. Here's a Fibonacci sequence in both languages.

First, Ruby:

x1, x2 = 0, 1
10.times do
  puts x2 
  x1, x2 = x2, x1+x2

Notice the parallel assignment in the first and fourth lines, letting you concisely express two different assignments. Also, notice that 10 is an object, and it supports methods, like times. Also, between do and end, you have a code block. Ruby code blocks let you pass fragments of code to a method. This technique leads to incredibly productive and concise code.

Now, look at a Java implementation of the same code:

class Fib {
  public static void main (String args[]) {
    int x1 = 0;
    int x2 = 1;
    int total = 1; 
    for (int i=0; i<10; i++) {
      total = x1+x2;
      x1 = x2;
      x2 = total;

You need to declare every variable, and spell out your iteration with the for loop. Each assignment is independent, so you must have a temporary holding variable for total.

So the dynamic languages are more concise. As a general rule, if you can write less code without sacrificing readability, less code leads to greater productivity. (But you can't sacrifice readability to get there, our you wind up with Perl, for example.)

More importantly, dynamic languages are better at important problems that Java developers want to solve, like metaprogramming. Hibernate uses metaprogramming techniques to make objects persistent. Spring uses metaprogramming to add services to Java objects without you having to build explicit support for them. The exploding Ruby on Rails framework takes good advantage of the capabilities in Ruby to build one of the most productive application development frameworks in existence.

The list of Java developers adopting Ruby is astounding. Ant and Tomcat inventor James Duncan Davidson is working on Ruby on Rails, and one of the bestselling Java authors and JSF (Java Server Faces) expert group member David Geary is writing a book on Ruby on Rails. Dozens of the brightest minds in the Java community are moving to more dynamic languages like Ruby because the newer languages better solve the most interesting problems. Dynamic languages will not completely replace Java, but they will be more attractive for small, lightweight problems.

Beyond Java

Related Reading

Beyond Java

Pages: 1, 2

Next Pagearrow