Thursday, April 09, 2009

Learning not to love Java

Back in 99, I spent about six months procrastinating over a MAJOR decision (or so it seemed at the time).

To stick with the Microsoft camp - where I'd built up substantial experience through ActiveX to DCOM to COM, IIS and Commerce Server 3.0 - or jump onto the Java bandwagon?

Ultimately, Java won out, and along with millions of others, we've made Java the enterprise platform of choice (arguably).

The interesting point upon reflection, is that there was never any doubt in my mind that Java was somehow 'better' and more 'pure', in an academic sense.

Almost ten years later, I shocked myself recently when returning to Java after spending a good part of the past two years infatuated with ruby and rails and other scripting languages.

Where before I saw classical elegance, now my first thoughts were this sux and the language is just getting in my way.

First the verbosity kills me:

WeLikeLongDescriptiveClassNames myReallyDescriptivelyNamedObject = WeLikeLongDescriptiveClassNamesFactory.getInstance(duh);

How many times do I have to tell the compiler what kind of object I am dealing with? Sure, I understand the benefits of the Factory pattern and the subtleties you can construct by virtue of the inheritance hierarchy. But most of the time, I just want the compiler to do what is most obvious, and don't make me write a novel for the most straight-forward tasks!

Then there's the language-promoted cultural phenomenon of class explosion. Need half a dozen value objects to represent the various information to be passed around in your domain? Sure! With unit tests all, I am sure. Most of the time, I'd now prefer to scream YAGNI!

But the true ephiphany was my run-in with primitives (again ... every year or so). Using JSP sessions as a perfect place to test this out. Take an int and stick it in the session:


int startingInt = 3;
session.setAttribute( "startingInt" , startingInt);

What type is in the session? An Integer object of course. Java has cleverly done a type conversion for you, from a primitive to an object. But woe betide the simple developer who assumes this must be a commutative operation:


int newInt = session.getAttribute( "startingInt" );
// Error!!

That's what I call a language actively getting in your way. Kind of like if you deposited $10 cash in your bank, but when you went to withdraw the money, the teller threw the shutters down and said you could only get your money back in government bonds.

So do I have a point or is this just a rant (and certainly one that is not as erudite as many have written)?

I guess I must be pretty slow to catch on to what others knew long ago. The true test comes down to being able to realise one's goals. For personal projects, I find I'm able to knock out complete (and impressive) applications in Rails, while I still have ten java-based ideas on the drawing board.

It comes down to whatever works. And it should.

Does that mean I hate Java? Not at all. I still get a bit of a thrill out of its clean lines and voluminous open source library support. Much like seeing an aging and long-since outclassed 512BB. 'Classic' is timeless.

No. I don't hate Java, but neither do I love it the way it used to demand. I look back on my naïve 1999-self in wonder. Building experience is key, but it is a mistake to tie this to a language. Computer languages are the tools of our trade, and the more you know, the better you will be. When people mention Haskell, Scala, Eiffel ... do you know what they are on about, or do you just nod intelligently and pray not to get caught out?

With more tools at our disposal, we are better able to tackle new challenges in the most appropriate way.

To get the job done (which is generally the point, right?).

18 comments:

atc said...

"So do I have a point or is this just a rant (and certainly one that is not as erudite as many have written)?"

Sarcasm? :)

Paul said...

Not at all. I've seen quite a number of posts that attempt to sum up the java pitfalls over the years. "Why Java is Obsolete" is a good one, linkworthy at a pinch;-)

DesktopFixture said...

I am an armchair analyst. I like thinking more than doing. Which is why I like the syntactical complexity of the Java platform, and MFC which I looked into recently to pass my time! I guess it's another reason why I fell into love with Linux'/Unix' command line way. But it turns out that this intellectual self-gratification doesn't amount to any thing. I wonder if there are more of my type.

grand.master03 said...

Its really a nice blog for....architects in bangalore , architects in bangalore , interior designers in Bangalore , interior designers in Bangalore , architects in bangalore , architects in bangalore , interior designers in bangalore

Rebeca said...

I love Java very much, its my first programming language and working on java for 3 years.

Ben said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Bruce said...
This comment has been removed by a blog administrator.
James said...
This comment has been removed by a blog administrator.
Paul said...
This comment has been removed by a blog administrator.
pariuri sportive said...

Thanks for sharing such a wonderful information with us, it really helps me slove my problem, keep up the good work. Cheers

Sheldon said...
This comment has been removed by a blog administrator.
Logo said...
This comment has been removed by a blog administrator.
custom papers said...
This comment has been removed by a blog administrator.
Faraz said...

LMAO.. I love the JAVA SUX number plate.. I'd love to have that on my jeep :)

-faraz from bluray ripper and blu ray rippers

Jamey said...

So what is so important about 'loving' a computer language? I would never asked myself that question. Really - who cares? I know what I do love - creating great solutions for my customers. Java lets me do that just as well as I could in any other language. And I consider myself a very proficient Python developer as well. Don't really care about loving that language either. The real world doesn't care what language we use. Grants

petkarter said...

Interesting that people dont like Java and it is mostly not the people but companies that makes you do it :)
BR, acne scar remedies

remi online said...

This is a great blog to model mine after. I hope you don’t mind if i bookmark your site, so that i can easily find it again in the future. Cheers