"no variable or argument declarations are necessary."

Roy Smith roy at panix.com
Fri Oct 7 14:16:12 CEST 2005

Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
> What this is about (to me at least) is the edit-debug cycle.  Let's
> say I write some Python code, using assert to validate datatypes.
> Maybe I've made 4 errors.  I then write a test function and run it.
> Boom, the first assert fails.  I fix the first error, run again.
> Boom, the next assert fails.  Fix the next error, run again, boom,
> fix, etc.  Four edit-debug cycles.
> With static typing, I run the compiler, get 4 error messages, fix all
> 4, and can get on with the next phase of testing with three fewer edit
> cycles.

That's certainly the plan, but my experience is that it's not the whole 
story, for a few reasons.

1) I can often run 4 Python edit-debug cycles in the time it takes me to 
run a single C++ cycle, especially if there's a whole pile of build system 
gunk layered on top of the raw compile step.

2) When I get a bunch of compile errors, I know that many of them are just 
cascaded from a single problem.  Thus, I tend to fix the first one and only 
take a quick look at all the others.  If it's obvious what the problem is, 
I'll fix it, but as often as not, I'll just recompile and see what pops out 
the next time.

3) Many times, I'll spend more time making the compiler happy than the 
protection it affords me is worth.  C++ is such a complex language, it's 
really hard to write a compiler which follows every detail of the spec, and 
the details are what kills you.  We had a case the other day where a 
const_cast of a reference returned by a function worked just fine on 
Solaris, but failed on HPUX.  We ended up with three guys digging through 
reference manuals trying to figure out how const_cast and references are 
supposed to interact.  We ended up deciding what we were doing was legal, 
but we still had to devise a work-around so it compiled on all platforms.  
It's actually a little more complex than that, because we don't even write 
raw const_cast's, we use a CONST_CAST macro to work around older compilers 
that don't support modern casting, so we burned a little more time 
double-checking that our macro expansion wasn't at fault.  We could have 
done a lot of Python edit-debug cycles in the time it took to sort that one 

More information about the Python-list mailing list