🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #4043

Re: Run-time Type Errors in Smalltalk

#4043
From: Doug Merritt
Date: Wed, 22 May 1991 18:52
52 lines
3337 bytes
In article <1991May20.172441.780@csc.canterbury.ac.nz> chisnall@cosc.canterbury.ac.nz writes:
>From article <1991May13.061520.11992@daffy.cs.wisc.edu>, by quale@khan.cs.wisc.edu (Douglas E. Quale):
>[...]
>> This statement suggests that programs compiled in dynamic languages contain
>> more type errors than similar programs written in statically typed languages.
>> Unfortunately I don't know of any studies that have been made that could
>> definitively affirm or deny this.  In fact, I don't know of any evidence at
>
>    "... This evidence indicated that the use of dynamically typed
>    operands resulted in errors that remain in programs longer than
>    the errors attributable to statically typed operands."

This is in fact trivially true. Errors caught at compile time are
guaranteed to be 100% detectable (and removable), whereas errors caught
at run time cannot be detected until just the right conditions occur,
so in arbitrary programs it will take arbitrarily long for all run time
errors to occur and be detected. Or even infinitely long, since proving
otherwise is the halting problem.

Therefore dynamically typed languages are inheritantly less safe than
strongly statically typed languages, because only in the latter can you
know that all type errors have been removed.

This is a minor point, though, because there are situations where dynamic
typing is a powerfully expressive and natural tool, and the desirability of 
such is (in some situations) far more important than merely increasing the
safety of type usage.

The reason why that is true is that if you really need dynamic typing,
but the language doesn't support it, then you have to implement it yourself
anyway (that's what e.g. C unions and Pascal variant records are *for*,
after all), and now you've written new code that may contain errors,
so you haven't really gained anything.

Note that this argument is algorithm-specific, and says nothing in support
of completely dynamically-typed languages over optionally dynamically-typed
languages.

BTW there's also an age-old esthetic criterion that "everything should be
a first class citizen", and it derives from the practical experience of
awkwardness of expression that results for certain applications if some
things are second class citizens. This is a somewhat stronger argument
than simply "dynamic typing"; it argues for dynamic typing of the strongest
sort, that allows type-values to manipulated via a calculus (ideally
via an algebra).

All in all, one really wants dynamic typing allowed, but optimized out
and statically checked where at all possible. This is a challenge for
language design (I'm working on it :-)
	Doug
-- 
Doug Merritt	doug@netcom.com		apple!netcom!doug
Technical Details
Message-ID: <1991May22.185227.9936@netcom.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!mips!apple!netcomsv!doug
References: <1991May13.061520.11992@daffy.cs.wisc.edu> <1991May20.172441.780@csc.canterbury.ac.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!mips!apple!netcomsv!doug
From: doug@netcom.COM (Doug Merritt)
Newsgroups: comp.lang.misc
Subject: Re: Run-time Type Errors in Smalltalk
Message-ID: <1991May22.185227.9936@netcom.COM>
Date: 22 May 91 18:52:27 GMT
References: <1991May13.061520.11992@daffy.cs.wisc.edu> <1991May20.172441.780@csc.canterbury.ac.nz>
Organization: Netcom - Online Communication Services  UNIX System {408 241-9760 guest}
Lines: 52