views:

421

answers:

3

I've been reading Bruce Eckel's Thinking In Java and in the chapter on generics, he briefly mentions the Nice programming language as something that handles parametrized types better than Java, but compiles into Java bytecode.

Does anyone have any experience with this? Generics make my head hurt, so the prospect of an alternative that interoperates with Java is appealing... but I sort of feel like it would be like trying to learn both French and Quebecois and getting yelled at if I get them mixed up in the wrong context. (no offense meant so please don't ding me for not being PC) And whoever thought up the name "Nice" should be shot, since it makes it impossible to search for any websites other than the sourceforge one.

+2  A: 

Maybe the question to ask is, "Why do generics make your head hurt?" How are you using them that causes such pain?

I'll agree that there are flaws with generics in Java, and there are situations (e.g., extends) that do cause problems, but what exactly is your issue?

Using another language that compiles to byte code might help you in the short run, but if you're working in a team that delivers systems that others will have to maintain you might have problems introducing a technology like Nice, no matter how elegant it is.

duffymo
Jason S
I'd say the answer is do the simple things and stay away from the stuff that makes your head hurt.
duffymo
+7  A: 

I'd also suggest looking at Scala, a multi-paradigm (OO and functional) language that runs on the JVM. Martin Odersky, the "father of Scala" was also a primary contributor to the implementation of generics in Java, including his work on the Pizza and GJ implementations.

The current type-erasure mechanism in Java does force one to understand some implementation details to make sense of restrictions, but it is fair to say that using full-blown generic support in any language is going to require a learning curve.

I found Java Generics and Collections to be a well-written introduction and guide to using generics in Java 5.

joel.neely
+1  A: 

I'd say look at Scala or Groovy. It's my impression that Nice is an experimental language that never caught traction. If you don't like Java's generics at all, then you might prefer groovy, which is dynamically typed. If you like the idea of generics, but find Java's implementation of them confusing (like I do), then you might like scala, which handles generics more sensibly.