On Wednesday, 4 June 2014 at 19:43:53 UTC, bearophile wrote:
Nick Sabalausky:
In my experience, using heavy dynamic typing throughout a
program creates far more work (mainly debugging) than it
avoids. Even in tiny ~100 line programs, I've spent large
amounts of time tracking down bugs a sane compiler would have
immediately pointed out with a comparatively negligible amount
of my effort spent on typing.
I think often this happens because you are trying to write
Python/Ruby code like you are using C++/Java, you assume the
compiler will catch certain kinds of bugs. If you write Python
with the kind of coding Python requires, taking more care of
the things the Python interpreter is not able to spot for you,
you will use much less time to debug Python code, and the
overall coding time will be quite low. In Python you write 2-3
lines of tests every 1 line of code, and you test every
functions for the corner cases you can think of. You don't
write more than few 3-6 lines of code without testing them
immediately. So for certain aspects you need more discipline to
write Python, while for other things it needs less. For small
and medium programs this leads to sufficiently correct Python
code :-) It's usually quite hard to explain such differences in
coding stile to people that are used to static typing.
Bye,
bearophile
I hear this concept again and again, still can't really get it.
You are trying to save some tiny portion of time of writing down
actual type to spend much more time in different mental context
to write several lines of tests to achieve exactly the same
thing? How can this ever be a reasonable trade-off?