Saturday, March 10, 2007

Java verses Javascript

So, I've been playing a lot with Javascript lately. I'm reminded just how versatile the language is. It's pretty neat to declaratively add a new element to some "class" or function.

I keep stumbling onto pages where the author dribbles on about how Javascript is more powerful than Java, etc. The sense I get is that they feel that Javascript is the more evolved and more suitable -- trash all that Java. Junkyard all that C#. Javascript to the rescue.

It sort of reminds me of the VB proponents a few years back, waving their flag in the face of we Java and C++ people. Bla. Give me a break. Right tool for the right job. In fact VB was very powerful and productive for developing "RAD" applications. Great for that departmental application that just had to work and be delivered quickly. Lousy for shipping that product to 10,000 customers; lousy for squeaking the last ounce of performance out of the CPU.

In fact Javascript is powerful and very flexible. But it is its flexibility that really damages productivity for larger projects. Refactoring sux. Debugging too often uncovers a typo. Live production too often turns up the simple logic error. Let's not mention the incompatibility between browser implementations of the DOM or Javascript.

The truth is, if the browsers supported a better implementation for developing AJAX applications in Java life would certainly be better. Static checking, better refactoring, and better software engineering controls. Maybe this is why I like Google Web Toolkit. It allows the developer to write the application in Java, test it in Java, then generate the final HTML/Javascript (which naturally must also be tested independently). And for the macho uber developers who (like some of us seasoned veterans) really like to stick to old-school development style, they can use the JSNI interface to interact with their own pure-Javascript creations. The latter sounds like those of us who used to insist that we needed to embed ASM into our C++ for performance and control. Geez: I don't miss those days...

No comments: