Re: Static vs. Dynamic typing
From: Richard Riehle (adaworks_at_earthlink.net)
Date: 09/08/04
- Next message: Richard Riehle: "Re: Static vs. Dynamic typing"
- Previous message: paul campbell: "Re: Coding inside the debugger"
- Maybe in reply to: Programmer Dude: "Re: Static vs. Dynamic typing"
- Next in thread: Isaac Gouy: "Re: Static vs. Dynamic typing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 08 Sep 2004 17:56:15 GMT
"Thomas G. Marshall" <tgm2tothe10thpower@replacetextwithnumber.hotmail.com>
wrote in message news:fJx%c.6042$wF4.2945@trndny09...
> Richard Riehle coughed up:
> >
> > Although this may seem like a minor thing when one is writing
> > programs in "the small," it is huge benefit when writing large,
> > complex programs where every capability for ensuring the
> > dependability of the software is important.
>
> Well that's the crux of the argument. The "huge benefit" you're talking
> about might not be so huge when take into account the added time it takes
to
> code in static languages.
>
In fact, for large programs, it takes no extra time to create code in
a "static" language. I will give you the argument for single programmer
programs of less than 50 KSLOC where there is a small team of
developers, and where dependability is not a high priority.
Moverover, static typing, at least in Ada, goes well beyond simple
type checking. It becomes a valuable design aid, as well as a
useful programming tool. For example, suppose I have the
following type,
type Color is (Red, Orange, Yellow, Green, Blue, Indigo, Violet);
type Day is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday);
subtype Weekday is Monday..Friday;
subtype Weekend is Saturday..Sunday;
and the following variables of the type
C1, C2 : Color; -- eventually given values
In an if statement, I can do the following membership test,
if C1 in Weekday then ...
taking advantage of the compiler's check that this is legal, and
using the compiler to generate code that can later be tested.
Also, in a case statement, I might have
case C2 is
when Weekday => -- do some operations
when Tuesday => -- do some operations
end case;
an incorrect construct that will be instantly caught by the compiler.
Why? Did I cover all the possible choices? No. The compiler
will reject this. Did I duplicate one of the choices? Yes. The
compiler will also reject this. I could cite thousands of examples
where this kind of thing is useful and, because it is caught by the
compiler, I never have to submit code to testing when the
compiler can identify patently wrong constructs.
Ada contains a built-in capability for concurrency, arguably one
of the best and most carefully designed model of concurrency
that exists in any language. Included in this model is a capability
for mutual exclusion, schedulability, and inter-task communication
that is orthogonal to the rest of the language.
Concurrency, even when done right, often defies anyone's ability
to test for correctness. This is a case where design, static typing,
and all the other static features of the language prove beneficial. I
realize that, when coding for concurrency in C++, one is handicapped
by the need to invoke the external environment, and in that case,
testing is the only confirmability resource. In Ada, a great many
problems one might encounter during testing in C++, or most other
languages, will be identified early by the compiler. More important,
the type model (tasks are themselves modeled as types) allows
design capabilities that are absent in languages without this
feature.
Simply put, testing, in large-scale software systems where human
life and safety are paramount, is just not sufficient. One must be
concerned with coherent, well-architected design. When a lot
of the errors can be detected early in the process, with type safety
being one of those detectable concerns, it would be foolish to
adopt an ideological intractability to test-driven design at the
expense of the reliability of the final software system.
Richard Riehle
- Next message: Richard Riehle: "Re: Static vs. Dynamic typing"
- Previous message: paul campbell: "Re: Coding inside the debugger"
- Maybe in reply to: Programmer Dude: "Re: Static vs. Dynamic typing"
- Next in thread: Isaac Gouy: "Re: Static vs. Dynamic typing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|