Saturday, May 31, 2008

Coding in java after a two year affair with ruby

I was a professional java developer from 1996 to 2006.  From 2007 to present I've been a professional ruby developer.  This last week I've been forced to work in java again and OMG.  As a co-worker put it "java is like filling out government forms... in triplicate."

Some quick points that make ruby fundamentally better:

  1. Having to declare what type a variable is, is pointless busy work.  If I want to say username = 'andrew' it's pretty obvious username is a String.  Why oh why java do you make me fill out that G973-1 String variable requisition form?
  2. Having to put a semi-colon at the end of each line is a waste of time;
  3. begin end is sooooo much better than { }
  4. Having to enclose all if statements with ( ) is dumb.
  5. Being able to say username = 'andrew' if boolean all on one line is poetic.  No poems allow in government forms.
  6. Single quotes for non-interpolated strings and double for interpolated please!
  7. And of course no blocks, no easy loops, no easy arrays with the arrow arrow operator, no built in hash with the brackets, and you have to compile it!
Blackberries are very nice, but RIM only allows development in Java and ONLY on Windows.  I was forced to get VMWare Fusion and a copy of Vista to run on my mac.  Ugh.

The verboseness of Java doesn't prevent bugs or make more maintainable code.  There, I said it.

7 comments:

Unknown said...

I know I'm asking for it... but seriously... have you tried http://groovy.codehaus.org/ ... no really, What did you think?

Geraldo Lopes de Souza said...

@shawn, whats wrong with jruby ? :)

Fiso said...

You can't compare Java with Ruby,
Java is pretty faster, and you can use it everywhere.
For me Ruby is a bullshit, very nice code with very bad performance.

Did you like Ruby's sugar-code ? Go to Groovy (Java-based) , you will love it more than Ruby ;)

Fiso said...

You can't compare Java with Ruby,
Java is pretty faster, and you can use it everywhere.
For me Ruby is a bullshit, very nice code with very bad performance.

Did you like Ruby's sugar-code ? Go to Groovy (Java-based) , you will love it more than Ruby ;)

Peter Lawrey said...

I can only guess you haven't been using IntelliJ. It does 1,2,3,4,5 for you.
Point 6 is a good point, but it can be easily supported in other ways.
Point 7, These are interesting points. Some of these features will be in Java 7 and other should be considered.

"you have to compile it!"

Actually, you don't have to compile Java and you can compile Ruby. This doesn't have anything to do with the language.
People compile their code because they don't have automated tests which checked that every line of code is valid. However I assume you don't care about whether your code would compile or not.

Tom Harrison said...

@Peter Lawry --

I agree that IDEA makes Java almost nice to work in (and of the several Ruby IDEs I have tried, none comes close to IDEA for Java). Still, even though Andrew's observations about Ruby are taking a lot of flack on DZone, after coding in Java for years , I find the freedom of Ruby liberating for many of the same seemingly trivial reasons as Andrew.

Georgi said...

Remembers me to Monty Python: "No it isn't, Argument is an intellectual process ... contradiction is just the automatic gainsaying of anything the other person says."

Where's your point, man? Comparing the all-new-Ruby to legacy-Java you could be doing better than that.