I’m in the same position too. Love Ruby but cannot recommend it
for team development w/o having the language provides some sort
of intrinsic interface validation.
Again: why? Why do you need intrinsic interface validation? As
Michael Campbell noted, if a library writer isn’t going to
document their code, what makes you think that they’re going to
put interface validation in there?
At some point, you ought to quit asking people why. They’ve
answered you on this question, and what you’re doing is
continually asking “why why why?”
Sorry, but you need to reread the type checking proponents’ posts
yourself if you think that what I’ve been told amount to “reasons.”
At best, they are excuses. I mean that quite charitably, as I don’t
think that anyone has deliberately avoided answering the question.
If you look a bit closely, Thien Vuong actually attempted to give an
answer, which was perhaps the clearest answer given so far. It’s
telling, then, that when I responded to him, he acknowledged that
what he’s after isn’t type checking, but assurance.
Just accept it. This is something people want. It’s getting
annoying hearing about how you can’t understand why they want it.
People want it, but without justification, I see no reason that they
should get it. Granted, I am not the person that makes the final
decision, but I feel that there’s a fundamental disconnect between
the people who want type checking and what they really need. I
cannot believe that dynamically typed languages are inherently
less productive and/or stable than statically typed languages. Nor
can I believe – without evidence (and the plural of anecdote is
not data) – that statically typed languages are superior for medium
to large teams.
Why do people who want type checking not want to explore alternative
mechanisms offered by Ruby – most notably automated unit testing,
or a DbC-style implementation? I’ve already pointed out that type
checking increases code fragility and repetition:
int max(int a, int b) { return a > b ? a : b; }
float max(float a, float b) { return a > b ? a : b; }
double max(double a, double b) { return a > b ? a : b; }
char max(char a, char b) { return a > b ? a : b; }
String max(String a, String b) { return a > b ? a : b; }
Complex max(Complex a, Complex b) { return a > b ? a : b; }
or:
def max(a, b); a > b ? a : b; end
This is duck typing at its best: as long as a can be compared
against b (either by supporting #> directly or through #<=>), then
max will work for the specified classes. We don’t even have to be
comparing two of the same types.
If I try to do max(3.0, 4) or max(3, 4.0), the C++ compiler is
confused.
max.cpp:11: error: call of overloaded max(double, int)' is ambiguous max.cpp:3: error: candidates are: int max(int, int) max.cpp:4: error: float max(float, float) max.cpp:5: error: double max(double, double) max.cpp:6: error: char max(char, char) max.cpp:12: error: call of overloaded max(int, double)’ is
ambiguous
max.cpp:3: error: candidates are: int max(int, int)
max.cpp:4: error: float max(float, float)
max.cpp:5: error: double max(double, double)
max.cpp:6: error: char max(char, char)
In comparison, the Ruby version just does the right thing. A lot of
extra work needs to be done to predict solutions with typed
languages. You yourself said you don’t care for C++ templates, and I
can’t disagree – they’re ugly and unwieldy. If there’s anything
that requires a brilliant programmer to deal with, it’s C++
templates. Ruby, on the flip side, isn’t nearly as confusing as C++
templates.
What again, does static typing buy you that test driven development
doesn’t deliver better – in spades?
That’s what no one in this discussion has been able to explain.
The broad statement is made: “I need interface validation!” But
no convincing explanation as to why it’s needed is made, either.
OR why interface validation is preferred to DbC or TDD – both of
which I consider to be superior techniques to compile time type
checking.
Explanations have been offered, you’ve just chosen to remain
unconvinced or have ignored them. They are there. Go browse back
and look.
Sorry, but “I need it because I want to avoid questions” (sorry,
Simon) isn’t an answer. Neither is your apparent favourite: “I just
need it, that’s why.”
-austin
···
On Fri, 21 Nov 2003 02:20:04 +0900, Sean O’Dell wrote:
On Wednesday 19 November 2003 10:47 pm, Austin Ziegler wrote:
On Thu, 20 Nov 2003 14:52:17 +0900, Thien Vuong wrote:
–
austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.11.20
* 13.54.02