Practice type-rich programming
So far, I’ve focused primarily on efficiency, but ef-
ficiency is irrelevant if the code contains critical errors.
Addressing the issue of correctness requires making prog-
ress on two fronts:
•
eliminate programming errors (make such errors less
likely and more easily spotted), and
•
make it easier to analyze a program for design errors
(in general, make it easier to build tools that manipu-
late programs).
The distinction between a design error and a program-
ming error isn’t completely clear. My practical definition is
that programming errors are those that can be caught by a
good production compiler; they involve inconsistent use of
values and don’t require extensive computation to detect.
Design errors involve plausible-looking code that just hap-
pens to do the wrong thing. Catching design errors requires
tools that “understand” the semantics of higher-level op-
erations. Even a compiler can be such a tool if semantic
0
1,250
2,500
3,750
5,000
1
2
3
4
5
Seconds
Vector
List
Preallocated list
Do'stlaringiz bilan baham: |