Re: Why use C++?
On Aug 23, 9:47 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
On Aug 22, 12:44 am, James Kanze <james.ka...@gmail.com> wrote:
And the "bad"
techniques, like just typing in code without having done any
design, don't really make such a difference in very small
I still sort of desing I just don't write it down.
You don't "know" something until you've written it down. It's
too easy to cut corners otherwise.
It's not a question of "liking": static typing saves you from
all kinds of problems once the program gets a bit bigger.
not entirely convinced. I suppose with dynamic typing you have to make
sure all the code has executed so thre isn't some time bomb hiding in
your code. But your C++ code should have pretty thourogh test coverage
Static typing results in a compile time error on the exact line
where the error occurs. Dynamic typing requires running the
program. On large programs, that takes more time, and the
resulting error message is generally less precise (although I'll
admit that Python can give fairly good error messages in this
case). There's an old saying that every step you go through
until the error appears multiplies the cost by 10; an error
caught by the compiler is 10 times cheaper to fix than one
caught in unit tests (or 100, if you count linking as a separate
step). The factor has obviously been pulled out of thin air,
but there is something to the general principle: an error found
by the compiler is cheaper to fix than one found in code review,
or one found in unit tests.
Note that on very large projects, a type error in the interface
between subsystems may not show up until integration, and
resolving errors which first appear in integration can be very
Most of my experience has been on large projects, in large
teams, and on systems which were more or less critical. All of
which argues in favor of very strict static typing. (IMHO, C++
isn't strict enough.) On the other hand, in all of these
projects, there's been a lot of support code---code and
documentation generators, verification programs, test suite
generators, etc.---and these have largely been written in the
Bourne shell, with intensive use of AWK.