Monday, January 14, 2008

Everything Looks Like a Nail

I've heard it before here and there, but it exactly describes how I feel working with Java for the last few years.

"If all you have is a hammer, then everything looks like a nail."

I've been writing code for over 20 years now; C, C++, Smalltalk, Java, C#, Python, Ruby, etc. When I went to school, we were taught Pascal, C, Cobol (now that sure dates me) because the school I went to wanted to get me ready for the "real world" and that world was using those languages at the time. Admittedly, I didn't learn much in school. I didn't learn much about computer science. I learned plenty about how to build simple CRUD applications using imperative programming languages. Sure, we all used SQL, but didn't spend much time understanding it. Think about programmers today, most know enough SQL to get the job done. How many times have you seen SQL stored-procedure code written... well... procedurally? I bet more than a few. Did you even notice? Did you care? I didn't. I should have.

Java Sucks

I'm not going to sit here and tell you that Java sucks, but... well... Java sucks. Why? Because there's no evolution of the language. Imperative only. Cruft everywhere. Powerless scoping rules. And, most importantly, it's limited my ability to think about problems in different ways. I naturally think procedural - give me Lisp, Haskell... forget it. I've inadvertently trained myself to only see nails.

Java is Powerful

Huge community. Many tested frameworks. I want to leverage that community, those frameworks. I want to make them better. I sure as hell don't want to start again. I'm not going to rewrite Hibernate. I don't want to rewrite Wicket. I don't want to rewrite JScience.

Why Not Ruby?

I was there for a while, but I can't stay. I really love the language. It' has almost everything I need. It has a large community. So why not? I don't want to invest my time into a toy. Sorry Ruby people, I only have enough bandwidth for one, and I see too many fundamental problems. No compiler. Not type-safe. (dodging bullets) No concurrency. Hey, I was in that community and put up with all those problems because I couldn't take Java anymore. Now I don't have to.


Scala

Scala, introduced to me by a colleague who's always on the lookout for a better way, seems to really impress. It's multi-paradigm; object-oriented, functional, concurrent. It's type-safe! Yeah! Powerful generics! Yeah! Closures! Yeah! Type-safe mix-ins! Yeah! Oh... did I mention... (cue the drum roll) it's Java! Can you imagine trying to write cross-cutting mix-ins in Java? Scala generates .class files that run in the standard Java 5 virtual machine. You want to leverage your favorite Java framework? Go ahead. No problem. What? You want your Java team to leverage a library you wrote in Scala? No problem. One drawback, and not really a language drawback, is the learning curve for all of us that see only nails.

Some of you are thinking "what the hell is he talking about?". "What's wrong with doing it the traditional way? 99% of the software we use today is built using imperative programming and they work just fine". Well yes, back some 2000 years ago, 99% or homes were built using straw and clay. They were just fine then too. Since then, homes have evolved because people wanted more. Today, people are smarter, tools are better. We want more.

Tools

Ouch. Scala isn't there. Getting better, yes, but it needs some time. Unless the tools get there, the masses won't come for the longer term. I won't come for the long term if the tools don't evolve. I've invested in Eclipse as a tool and a platform. For me, it's as important as the language - especially if the language is cumbersome. I'm not going back to vi and print statements. Forget it. I don't care how great the language is. Thankfully, Scala has an Eclipse plugin that at least gives me the critical stuff, i.e. debugger, syntax highlighting, etc. It's getting there. It just needs some time.

Give it a try.