Wednesday, April 21, 2010

Whenever I write code in Java....

Whenever I write code in Java I feel like I'm filling out endless forms in triplicate.

“Ok, sir, I'll just need your type signature here, here, and ... here. Now will this be everything, or...”

‘Well, I might need to raise an exception.‘

The compiler purses its lips.“An exception? Hmmm... let's see.... Yes, I think we can do that... I have the form over here... Yes, here it is. Now I need you to list all the exceptions you expect to raise here. Oh, wait, you have other classes? We'll have to file an amendment to them. Just put the type signature here, here, ... yes, copy that list of exceptions....

28 comments:

cdmckay said...

An ellipsis has three dots.

Also, I agree that Java is verbose.

Marek Krj said...

funny :-), but there's something to it

Kingwulf said...

you prefer PHP?

eliasp said...

It seems like some languages/frameworks could desperately need some DRY overhauling.

magicduncan said...

Ha! Well put indeed.

shevy said...

Prefering PHP over Java?

Sane men use elegant languages.

Like Ruby.

The goal should be to strive make languages as beautiful and elegant as possible. But that takes brain in design, and Java was designed by a corporate moloch to extend control of the economy. No surprise you find jobs as a java guy - it is a market speak language.

But not a programming language!!!

www.ithoughts.de said...

Just begin to use an IDE instead of a text-editor and you'll be fine.

mberube said...

An IDE doesn't make Java less verbose. Writing the code is one thing, but most of my time is spent reading it. That's when the verbosity hurts.

Unknown said...

@cdmckay: Yes an ellipsis does have three dots. A period has one dot. Even if a sentence ends with an ellipsis, it still must be terminated with a period.

ThinkEddy said...

If only there were an agile framework built on Java that plays nice with my current Java libraries that would allow me to create applications faster without all the verbosity. http://groovy.codehaus.org/

Bern said...

Came here to harp on about Groovy and ThinkEddy had beaten me to it.

I also recommend that you look at Groovy.

ChrisChiesa said...

An ellipsis at the end of a sentence is three dots, followed by a period. He/she did it right.

sanity said...

One word: Scala

Nor said...

give me a break. ever code in C++? this isn't unique to Java, noob.

Unknown said...

Yes, an IDE can help: "you see, now you can fill all this forms online and print the resulting document... oh, yes, if you need to correct it, you have to fill it again... no, the form doesn't allow to save it"

Creigh said...

We wouldn't be saying this a few years ago. Still, we use reference impl where we can and its tough to see them allowing scala in the src. Even though runs on jvm, call java libraries... etc.

Colin Howe said...
This comment has been removed by the author.
Colin Howe said...

Awesome. We both get hacked off by the same thing and blog about it at nearly the same time :)

My take on it.

steve said...

I might get hate for this, but whatever...
I am really starting to enjoy coding in Objective C. I like the syntax, the messaging, the split header/implementation files, and yes, even the memory management.
Objective C is certainly verbose, but not in the "I'm repeating myself everywhere" kind of way. It's more like spoken language, which makes sense to me.

That said, I am not a fan of Java or it's slightly more attractive sister, C#. Not because of the languages themselves, but because in order to do anything meaningful with them, you need lots and lots of framework infrastructure. The heck with that. I just want to write a piece of code, compile it, and run it.

And Ruby...that's just Python with a fauxhawk. Still, it's a nice language, in an "everyone's a winner" special olympics kind of way.
"Aw man...we built this thing on Rails! We did it in like 20 minutes! Step 3: Profit!!!" Good for you.

Tomasz Skutnik said...

I can't belive that nobody mentioned Clojure yet. I work in quite busy Java shop, and we use Clojure in production.

It's lisp (should be close to jrm heart) and has seamless integration with native Java libraries.

But maybe I'm just preaching to the choir.

Resuna said...

This is what reflection is for. If you can't solve this problem with reflection, then you don't really have reflection.

Josh said...

Maybe you just need to learn to type faster. I don't think type definitions are what's causing you to be a slow coder anymore then I believe your typing skills are. If you can think up a whole program faster then typing "String x = new String()" ... well you're a better man then I.

Jason Tovey said...

Regarding ending a sentence with an ellipsis, there should be a space between the ellipsis and the period. Putting four dots ala George Lucas is incorrect....

Jitendra Singh said...

We need to accept it’s a language for lesser mortals :-) who would write code where exceptions "will" happen and hence it gives a pre-defined way to handle it ...

Only we should ask java ppl to put Statutory warning "injurious" for others :-P

Unknown said...

I think the problem with Java is not it's verbosity, but as someone else said "infrastructure framework". I have to go through so many classes, through so much leaps and bounds, to do anything.

I need a factory, to create a manager. Then I factor anther factory, to create a stream, then assign that stream to the manager. Afterwords, I give the manager to a dispatcher.

Then there is an uncaught exception and I have to sift through 50 lines of junk to actually find out what went wrong.

Jeff said...

I agree with @www.ithoughts.de; just use an IDE. Sure, writing Java code is a little more verbose. IDE's make it completely painless and add a lot of value (auto complete, javadocs, references, refactoring, etc) which you just don't see in the Ruby/Scala/Clojure communities.

Btw, good Java developers avoid all the crapy api's and use good ones instead (like Spring, Apache commons, etc). The standard Java apis are so-so. IMO, the value of Java is in the JRE and the third-party packages.

I disagree that verbose code is less readable. I think its way more readable because you can tell what is going on if your not a language super-guru. See: Perl and BrainF*ck.

I've tried most all of the latest-fad languages (ruby, groovy, scala, etc). Sure, they are neat for a little web site. I fear they are totally unmaintainable for large (100k+) code bases.

Real serious projects require real serious tools. Some day languages like ruby will grow up to fill that role but they just aren't there yet.

Mengu said...

@ThinkEddy, try play framework: http://www.playframework.org/

conclusion: play framework is the best thing happened to java.

Resuna said...

IDEs help you write code, but they don't help you understand or modify the resulting code, unless they completely hide the resulting code (the way Yacc and Lex do) and let you work in an application-specific meta-language. That's where reflection comes in... it makes the creation of an application-specific meta-language part of the language's own toolkit.