views:

244

answers:

1

Having been spoiled by ruby for so long, I now find myself having to do some Java development (Eclipse RCP). I'm wondering if anyone knows of alternatives to HashMap & ArrayList that have some of the sugar of ruby. The verbosity of dealing with an ArrayList of HashMaps drives me bonkers.

I'm also interested in finding other Ruby language sugar that people may have brought back to java, so any suggestions appreciated. You'll be helping make my current purgatory better.

+1  A: 

A lot of the ruby "syntactic sugar" is enabled by the use of blocks (closures) which Java doesn't have.

The Google Collections library has a lot of enhancements to the Collections API including support for a lot of a new data structures. The authors have tried hard to make collections easier to work with (especially when using Generics), but I don't think you're you're going to find the elegance of working with Ruby.

I don't think there were any major language changes in Java 6; Java 7, currently in the works, has something called Project Coin but those are fairly small language changes - no big changes like Closure support.

Ken Liu
Coin *does* however include "Language support for Collections", which would allow stuff like `someList[i++] = x` and `someMap["key"] = value`. http://blogs.sun.com/darcy/entry/project_coin_final_five
gustafc
agreed, that will be a pretty ncie feature!
Ken Liu