From comp.lang.smalltalk
- > > Big difference. That's because good unit tests are designed to
- > > support semantic verification. Types are just implementation details
- > > to help the compiler. (And anyone who has written a
Java/C/C++ compiler knows this is the truth!)
- > - > And how are unit tests dependent on casts?
Please, pardon the intrusion.
I haven't been following the whole argument,
but it looks like you're having a grand old time,
and I'm hesitant to interrupt.
I'm not trying to argue against either one of you - in fact,
I'm not even sure if what I'm saying is related to what you're saying.
I'd just like to say it, because you reminded me of it.
I've been using Smalltalk for a while lately, after having been a Java fan.
I've also been learning a whole lot about Extreme Programming,
and in particular about unit tests.
One of the things that I used to love most about Java
was how easy it was to find problems. I'd come from C++
before that, and in comparison to the C++ environment
I'd been using, Java compilers were wonderful.
Error messages that told me exactly what was wrong.
I didn't have to decode them, or figure out which
of a few dozen messages was the actual problem.
Also, the language was a lot simpler than C++,
so lots of the problems that I used to have
just went away, because they couldn't happen.
So I was pretty happy with Java. I'd heard of Smalltalk,
and I thought - the idea was neat, but I couldn't get over
this "dynamic typing" thing. How could that possibly work?
The compiler wouldn't be able to tell me anything.
Then I stumbled across Wiki, and started reading about
Extreme Programming. I thought that this was absolutely
the greatest thing I'd ever heard of since Java,
so I started trying little bits of it for myself.
Unit tests were the first thing. I downloaded JUnit and
started up a new little project of my own to try it out.
It was great, of course.
Unit tests make everything go so much faster.
I had a lot more confidence in my code, too -
with the Java compiler *and* my unit tests,
I was finding mistakes faster than ever.
Then it occurred to me to consider Smalltalk again.
After all, Kent Beck and those other XP guys liked it,
didn't they? My faith in them was - pretty high - certainly
high enough to spend a bit of my time trying out something
that I could get for free so I downloaded Dolphin and SUnit
and restarted my little project in Smalltalk.
The Smalltalkers out there have already guessed where I'm going.
I started noticing that I wasn't having any extra trouble finding bugs.
The Smalltalk compiler didn't help much, but the unit tests took up
the slack with no trouble at all. They found the problems just as early
as the Java compiler would've, because I was running the unit tests
all the time. No more than a few minutes in between each run,
and usually more - like 30 seconds. More often than I used to run
the Java compiler, because Smalltalk compile times are near-instantaneous.
(Of course, - it was a pretty small program - never more than 3000 lines,
plus 2000 lines of test code. The tests always ran in less than a second.)
So where were all these bugs that were supposed to slip through
and bite me at runtime? I fired up the program and tried to find them.
I couldn't. I tried everything I could think of. Still no problems.
Maybe they're in there. I don't know. For the time being, though,
I'm forced to conclude that the lack of static typing just isn't a problem.
At least, not if you have tests. Maybe it's not even a problem
if you don't have the tests, but I sure don't want to try it.
Everything goes faster with the tests anyway.
In hindsight, it was obvious. The tests handle type-checking for free.
The types have gotta be right for the program to work, and the tests
will catch type errors just as well as they'll catch anything else.
I'll still use Java without complaining too much.
The Smalltalk environments have spoiled me rotten,
but I hear that VisualAge for Java is pretty good.
I don't mind the syntax of either language.
I don't even mind the static typing, really.
It's sure not helping me much, though.