New Horizons

Keep in mind that I'm a cynic at heart. When it comes to technologies, it takes a whole lot of effort to get me excited. I still have never written a web service, at least with the massive IBM and Microsoft stacks, and I didn't write my first EJB until 2003. I've never written an EJB entity bean unless it was to build a case against them, and never will. I've instead preferred simpler architectures, like REST, POJO programming, transparent persistence, and Spring. Even then, I was late to those parties.

It's even tougher to get me to play with a new language. Dave Thomas, a highly respected programmer and a gifted teacher, is fond of saying that you should learn a new programming language every couple of months. I've probably averaged one every five years, and I rarely do more than dabble. But recently, in my dabbling, I've found a couple of startling innovations. These frameworks had ideas that just about reached out and ripped me out of my chair this year.

I've taken a little more time than usual to survey the interesting innovations around new programming languages. When it comes to building web pages and application servers, two ideas have my undivided attention: metaprogramming (like Ruby on Rails) and continuation servers (like Seaside on Smalltalk). Neither of these two innovations is happening with much impact in Java. You'll get a deeper treatment in Chapters 7 and 8, but it's enough to say for now that they are both many times more productive than their Java alternatives.

Dynamic Languages

Java is a language with many compromises . Many of the features of Java are appropriate for building operating system extensions and middleware, but limit application development. Consider this Ruby fragment:

    something = "Owls and Ostriches"
    4.times {puts something}

These simple little lines of code print Owls and Ostriches four times. Look at the power in this language:

  • You don't have to worry about details like typing, if you don't want to. If it walks like a duck and quacks like a duck, Ruby will type it as a duck. This saves more time than you think.

  • 4 is an object. Everything is an object. You can send methods to a 4, or a string, just like any other object in the system.

  • {puts something} is a code block. You can pass a code block as a parameter, and Ruby lets methods deal with the code blocks. This construct dramatically simplifies things like iteration, and lets you quickly customize the inside of a loop in a library.

Taken by themselves, these features can make you much more productive. But add the other features of a dynamic language, and you can see incredible power and productivity very quickly. Many of the so-called scripting languages make much more sense for application developers.


The Java community is now investing enormous energy into programming styles that are more transparent, reflective, and dynamic. These approaches are called metaprogramming , because they spend more time in the realm of the class than the object. It makes sense that you can get more leverage that way. Transparent persistence frameworks like Hibernate teach generic classes and collections to be persistent. AOP lets you extend a specified list of methods with custom code, without requiring modifications of that method. These problems are metaprogramming problems.

When Java experts get excited about metaprogramming, they often wind up adopting other languages. Want some examples? David Geary, one of Java's most successful authors and JSF expert group member, is aggressively learning Ruby on Rails , and is writing a Rails book. James Duncan Davidson, creator of Tomcat and Ant, left the Java community to code Objective C for the Mac environment. And, as you have seen, Justin Gehtland and I are using Rails to implement a web-based application for a start-up.

Think of metaprogramming as building a high-level builder. Ruby on Rails, for example, discovers the columns and relationships in a database schema, and uses that data to build a model, view, and controller for a web application. The characteristics of the environment are striking:

  • It's incredibly productive. It's easily five times as productive as the closest Java competitor, for certain types of problems.

  • It is flexible. Some solutions build a default application and allow common extension points. Rails builds a default application, which you can extend as if you'd written it yourself.

  • It reduces duplication, and leads to more consistency.

To me, for enterprise application development , the overriding characteristic of a language or environment is productivity . I want each line of code to work harder, and I want that to translate into productivity. I don't quit measuring productivity after deployment. If your tiny application is impossible to maintain, you'll lose everything you've gained. For these reasons, I love Ruby on Rails, and I'll talk more about it in Chapter 7.

Continuation Servers

Java web developers spend an incredible amount of time managing state, threads, and the Back button. These problems get significantly more difficult as sites get more dynamic and complex. There's been a recent resurgence in Smalltalk, and most of it centers around a framework called Seaside. Since continuations maintain state, continuation-based servers don't have any problem managing state. They also handle Back buttons and threading with relative ease. This framework uses a language feature called continuations to maintain state within a web-based application.

I don't mean to say that Smalltalk or Ruby will take over the world tomorrow. I don't even mean to say that anything will ever achieve the success that Java has, again. But I don't believe that Java is permanent. For five years, it's been a good strategy to ignore the borders beyond Java, but no language will keep its leadership position forever:

  • Java is moving away from its base. Hard-core enterprise problems may be easier to solve, but the simplest problems are getting harder to solve. And...

  • Java is showing signs of wear, and interesting innovations are beginning to appear outside of Java. So...

  • It's time to start paying attention again.

by BrainBellupdated