Re: "no variable or argument declarations are necessary."



Paul Rubin <http://phr.cx@xxxxxxxxxxxxxx> 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
out.
.



Relevant Pages

  • Some fixes for ZFS on 7-stable (more testers wanted)
    ... pjd - applicable to RELENG_7? ... Fix locking. ... NOT APPLICABLE to ZFS in 7-stable ... However, on ia64, the compiler is quite agressive in finding ILP ...
    (freebsd-stable)
  • Re: Is the following code MT-Safe?
    ... >>Explanation follows code example, MFC synchronization objects used ... > the first thread to resume, which then takes the assert. ... > volatile is unrelated to synchronization. ... > compiler to cache values, but only during the execution of a function; ...
    (microsoft.public.vc.mfc)
  • Re: STM32 ARM toolset advice?
    ... Compulsory car comparison: would you buy a car where the motor block is ... you yourself using a self-help book) can fix? ... compilers work better than a compiler vendor. ...
    (comp.arch.embedded)
  • Re: [PATCH 2/2] x86 platform driver: intelligent power sharing driver
    ... I bet the driver blows up and someone's logs get spammed;) ... Somehow the compiler will promote array ... Ah ok, will fix. ... don't trash callee's error code - propagate it. ...
    (Linux-Kernel)
  • Re: How many bytes per Italian character?
    ... There's a reason I don't use free open-source products: ... someone once said "Well, you should use gcc because that way, if you find a bug ... I used to work for a compiler company. ... *know* how hard it is to fix bugs in optimizing compilers. ...
    (microsoft.public.vc.mfc)