Tuesday, August 12, 2008

Java a OS?

For the last several weeks I had opportunities working on three vastly different projects, one built using old school Java + JDBC, one with JSF + Hibernate + Spring, the other one using Groovy + Grails. The experience of joggling among these three quite different projects every day (one with my day job, the other two with my night job - open source) actually reminded me a very interesting question that was asked during the 2008 Java One during James Goslin's talk. One of developer from the audience asked him a question like "Now Java has grown to a tremendous size with multiple languages supported, it feels more like an OS than a language" (can't really remember the exact question). James' answer was surprising straightforward, he said something like "Yes, that's what was intended from the very beginning" (again can't really remember the exact answer :-)

My experience in the past weeks showed me how much more productive and natural you can get while using the same set of API and Libraries (OS) but a different language. Even the best framework in Java can not stack up with the productivity you gain from Grails, based on my personal estimate the JSF/Hibernate/Spring stack is probably 3-4 times more productive than the simple Java approach. However productive it is comparing to the naked Java approach, the Groovy/Grails combo out-performed it about another 3-4 times (sometimes even more for the CRUD operations), mostly due to the opinionated framework, dynamic methods generation, code generation, and various ready to go plug-ins. If you look at the end result of the generated code by Grails, its pretty much as good as a Java application can be - a standard Spring + Hibernate architecture with full JEE compatibility enhanced with any plug-in you choose to deploy, built-in Ajax support, and fully unit testable with mock objects plus automated integration testability. So if you ask me now if I will ever start building another Java web application without using Groovy/Grails, I can hardly come up with a scenario that I will go with Java alone. Just as though you can implement the most sophisticated web 2.x site right now using C and CGI API alone but at what cost?

With JVM being a general purpose virtual machine or portable OS, we can predict many special purpose languages and DSL will be developed down the road in our never ending quest for the silver bullet. Even today you can already see the trend, people are now using Groovy or Jython for scripting, Grails or JRuby + Rrails for web development, Scala for concurrency or library building, and with of course a few touches of old school Java here and there some times. While for sure an exciting landscape for the Java community is ahead of us, it also reminds me a bit of the time when Java was still a new born baby, people were excited about Java and using it as an easy language to glue C and C++ code together through JNI, now as a full grown adult its time for Java to pass the torch. An exciting time indeed :-)

No comments: