From: "Adam P. Jenkins" Date: 2005-07-21T01:05:55+09:00 Subject: Re: Ruby/Rails as a starter language? Kev Jackson wrote: > The example of polymorphic dispatch could be done in Java, but only > just, and as this post suggests, with a load of reflection trickery - > pass in Class, get all the methods, find method named 'foo', create new > Method object, invoke and voila. It's just a two-liner in Java instead of a one-liner like in Ruby. I don't know where you and Devin are getting this idea that you need to "make extensive use of the Reflection API" and a "load of reflection trickery" to write polymorph or similar kinds of things in Java. Here it is, and I think it's very straightforward, if a bit more verbose than the equivalent Ruby code: Object polymorph(Object snufkin) throws Exception { Method m = snufkin.getClass().getMethod("foo", null); return m.invoke(snufkin, null); } Certainly Java wasn't designed to make duck typing convenient, but it does have quite a powerful and useful reflection API, which allows about as much of the Ruby reflection capabilities as makes sense in a statically typed language. Adam