Saturday 8 November 2008

Have we lost our way ?

I've been using Java since 1995 so must be one of the most experienced Java developers around but despite years of my life invested in this technology, I'm increasingly thinking that this has been a mistake.

When I first used Java, it was for writing Applets which is what it was really designed for i.e. object-oriented with a ready set of libraries for GUI widgets (AWT) and everything built-in to download and execute within a web page. Having come from C where it was very hard to build a GUI, Java was a huge step forward. How ironic, therefore, that I've never seen another decent Java GUI apart from Eclipse in all these years and instead we now use Java almost exclusively server-side for writing web applications and business components.

The types of applications that we build are invariably web applications with a database backend i.e. replacements for the old client/server applications that we wrote 10 - 15 years ago using 4GL's like Oracle Forms, dBase, Ingres OpenRoad, Pick or in my case Dataflex.

Java is an object-oriented general purpose 3GL and we are using it to write apps that we would have written with a 4GL ! Is it any wonder that there are so many Java jobs advertised or that organisations are having to recruit armies of programmers in India just to get their work done ? Productivity has nosedived.

I used to write entire modules (say 10 use cases) in Dataflex in a couple days. Now it takes me 2 - 3 weeks in Java even using the best frameworks the world has to offer. And using these 'great' frameworks I end up with dozens of Java files all glued together with untidy XML - what great progress when I would have had one or two Dataflex source files !

OK Java is a general purpose langauge and I can do things in Java that I could never have done in Dataflex but then how often do I need to do this ? In Dataflex, I could have glued some C code in to do something unusual if necessary, painful but still a possibility.

I've recently completed a couple of projects in Ruby on Rails and it has really opened my eyes to this situation that we've gotton ourselves into. Rails offers a big increase in productivity over Java but partly because it's a script langauge so it saves on the edit/compile/deploy debug cycle. One nice thing is that there is no nasty XML, all the code is in your Ruby source files. This means that it can be syntax checked by your editor and everything reads together. I don't particularly like Ruby as I find the syntax untidy and not intuitive. Java has a simpler and more regular syntax so is easier to learn, but there is no denying that Ruby on Rails is more productive partly because Rails uses mixins and symbols to create a semi-Domain Specific Langauge for web apps.

So why do all these Java frameworks rely on XML ? Simple - XML is being used to supplement the language because it's not extendable. People are trying to create a Domain Specific Language DSL, a higher level language, dare I say it - a 4GL but the language won't let them. Instead they are forced to use a data structure (XML) to do this. This is bad because the data structure is not a language and can't contain any logic. So we end up with more and more convoluted and unfathomable XML and masses of disconnected Java classes e.g. Spring - nice try but wrong approach. We have lost our way.

So, how do we get out of this mess and recover our productivity ?

Having recently discovered Functional Programming through Scheme (a Lisp dialect), I can easily see how Scheme would readily support the creation of a high level DSL whilst offering the full power of the underlying language. There aren't many people using Scheme at the moment so not many frameworks out there but there is a growing following and it feels right.

Maybe Scala is the answer ? Scala is a replacement Object Oriented language for the JVM that also supports functional programming.

No comments:

Post a Comment