“Volkmann, Mark” Mark.Volkmann@AGEDWARDS.com writes:
I’m curious how some of you that have written real
applications in Ruby have
dealt with this. Don’t you have problems where an
application crashes on a
user because the wrong type of object gets passed to a
method and it tries
to invoke a method of the object that it doesn’t have?
I love Ruby syntax, but this issue may be one that keeps
many people using
But Java has run-time type checking as well. Consider an average
running Java program. How many objects are extant? 1,000? 2,000? How
many variables do you have? 20? 30? So, where are all the other
objects? In collections. And how do you get to them? By casting at
every access. The type gets discovered at run time.
How many class cast exceptions do you see in Java? In reality, not
That matches my experience. I don’t see ClassCastExceptions all that often.
However, I think I would if it wasn’t for compile-time type checking.
In the same way, I don’t often see the wrong kind of object being used
in Ruby. However, to ensure that, I have to exercise the various paths
through the code, so I rely on unit tests to give me the confidence
that my code is reasonable.
Would you agree that with Ruby you have to write more unit tests than you do
in Java? You need to test that the types of parameters being passed to every
method are what was expected. It seems that this would cut into the
productivity gains in writing the actual code when compared to Java.
Even better than compile-time type checking is the fact that my IDE, IDEA,
flags parameter type issues before I even compile. I wish there was a Ruby
IDE that could do that.
I really want to be convinced that this whole type checking thing is a
non-issue for Ruby, but I’m not quite there yet.
WARNING: All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.