Wednesday, December 19, 2007

Java's Worst Enemy

Just read this awesome post by Steve Yegge about code bloat. Be warned: his post is really really long. (But worth the time.)

It ends up turning into an anti-Java rant, but I am fine with that. I remember when Tyler and I wrote Satupoly in Java during EECS 448 and at the time it just seemed like the best programming language ever. It had a ton of libraries to do what we wanted, and was really well documented. The tools for it were all free.

I can't argue with the plethora of libraries, but looking back now, I am kind of ashamed to have liked it so much. I think the reason it worked so well for us is because we hadn't tasted the dynamic language syntactically-sugared kool-aid yet... and because we didn't bother to follow any design patterns (other than good old MVC).

It could also be that Java has just changed a lot over the years. This was 2003 after all. I look at the code in front of me at work, and just see miles of bloat. I have been spoiled by Ruby's method_missing, thanks to which I haven't had to write out a billion getters and setters in a long time. I'm really spoiled by dynamic typing, which just seems so much more flexible and less whiny to me than static typing is. Add to that my love of passing around anonymous functions as data (thanks a lot Scheme and Javascript!) and closures, and Java is really becoming tiresome.

It's just strange now, to view with such derision something I loved so much back then. It's not just the code for this project either. I have tried to refactor it and DRY it up, but it's just really hard to get much out of it. You have to have getters and setters. You have to have big constructors. You have to have silly Hibernate xml files and implement all the CRUD in a frenzy of copy and pasted methods. Just trying to push standardized CRUD down into an abstract base class was a nightmare. Where is my macro to build these methods and add them to the object on the fly? All this explicit casting is going to break my brain. Why do I have to use objects just to hold enumerable options to pass to yet other objects? It doesn't feel like coding anymore, it feels like trying to make a movie by assembling a puzzle for each frame on the reel.

I don't think any language is really objectively better than another, let alone that one of them is the best. I do, however, think that, subjectively, Java is really excruciating... for me.

Oh, and I failed last night on doing something not-behind-the-scenes. I did however hack together a really neat HAML plugin that I hope to show off once I add some more features. It literally made my night when it worked.

0 comments: