Could Python supplant Java?
wurmy at earthlink.net
Thu Aug 22 06:39:55 CEST 2002
>>I might have thought the same a year ago, but since then I've adopted
>>test-driven development (TDD) which grew out of XP. Refactoring like
>>this becomes a breeze with a set of tests you can count on to check
>>not only the types of your objects, when that's important, but also
>>the logic, the inputs and outputs, and anything else that could
>>reasonably fail. With static typed languages, you get only the one
>>fairly trivial type of checking.
>>TDD and Python are an *excellent* fit, since TDD benefits greatly from
>>Python's very dynamic nature and flexilibity, while TDD supports
>>Python almost perfectly in one area where it seems many feel it has
>>a weakness - compile-time error checking.
> So you rewrite a compiler worth of tests on each project? This almost
> sounds as a good reason to stick to statically typed languages: at
> least, half the tests have already been written for you.
Not really. In my current project, I have a test suite that has 232 tests (and
counting...), none of which check the type of objects, or if functions are
called with the right number of parameters, or other stuff that a compiled
language would check. You use tests to check, generally speaking, if your code
does the right thing in various circumstances.
However, a nice side effect is that if your code contains bugs of other kinds,
like incorrect types, invalid function calls, and such, that your test suite
will find these as well. Without the tests, you'd have to run the program by
hand and usually you won't find such bugs until the program actually executes
the code. The tests take this part out of your hands, by running it automatically.
A well-written test suite will find such bugs early, so you won't see them for
the first time when you install your program on the production server and the
customer does something unexpected. :-)
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
More information about the Python-list