null [re: spec#] (on dynamic typing)

spir denis.spir at gmail.com
Thu Nov 25 11:08:53 PST 2010


On Thu, 25 Nov 2010 16:14:11 +0000
Bruno Medeiros <brunodomedeiros+spam at com.gmail> wrote:

> What they don't realize, is that static typing is just compile-time 
> unit-testing. :)

I tried to find some light on this topic a while ago, because similar arguments are constantly brought on the carpet, but I have never read any rationale, even less a report from an experimental study. Would be interesting; but what is to measure, exactly?
For a while, I have used nearly only dynamic languages; and I had bugs, some of them really naughty. Then about 2 years I passed on the stacic far more bugs, most of them not naughty at all. The sheer wasx partly due to less experience, but also because there are many more oportunities for bugs to come up, from plain language complexity (not only of syntax).

I start to appreciate static checking. During the first "static" year, I used mainly freepascal and can say I had about _no_ type error -- what static checking is here to catch, I guess. I think the reason was that during those dynamic years I had developed a kind of unconscious type rigor both on the modeling & the implementation sides of the coin.
These, I get many of them ;-) Wildly counted, after 1 hour typing without compilation, I get a dozen compiler errors, 1 serious, 2-3 type errors, the rest plain grammatical. I guess i'm slowly losing this purely mental typing discipline: static checking makes my brain lazy ;-); it relies on the compiler instead of thinking clearly. Or it's just age...

More seriously, I tried to classify programming errors. Let's say one need to model dice. After all irrelevant aspect removed, just remains equiprobable alea in a natural interval.
1. Modeling error: bite hard -- using a distribution that does not provide equiprobability.
2. Translation error: hurt as well -- random.int(1,6) actually returns in interval [1,5].
3. Implementation error: eg uint<-->int issues. Depending on the language, this risk may be caught or not. (Yes, there should be a huge number of dice with a huge number of faces...)
4. Grammatical error: except for beginners, harmless.

Phase 2-->3 is, for me, where we pass from human (model) semantic to language semantics. I guess that's where type issues may come up.
I'm aware this classification is personal, arbitrary, not based on any fact. Just tried to think about the question: what kinds of bugs do Type Errors reveal?


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list