Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!purdue!haven!ni.umd.edu!uc780.umd.edu!cs450a03 From: cs450a03@uc780.umd.edu Newsgroups: comp.lang.misc Subject: RE: Dynamic typing (part 3) Message-ID: <13MAR91.00251986@uc780.umd.edu> Date: 13 Mar 91 00:25:19 GMT References: <602@optima.cs.arizona.edu> <1991Mar13.010946.4536@engage.enet.dec.com> Sender: usenet@ni.umd.edu (USENET News System) Organization: The University of Maryland University College Lines: 65 The Question, as I understand it, is: Is it a "good thing" or a "bad thing" to require programmers to specify what types of information can be associated with a variable name. Sample argument for: Static typing catches errors. Sample argument against: Static typing encourages errors. Other argument against: Static typing slows development. Other argument for: Static typing allows faster code. Is that the gist of this, so far? Do I need to add that people favoring dynamic typing also favor dynamic testing? Or that existing popular systems (X-windows and emacs come to mind) are not paragons of efficiency? My own, biased, observation is that keeping information and control paths simple goes a long, long way towards catching errors. Static typing, as a sort of globalish way of specifying data by side effect often does little towards simplifying either control or data flow. The problem being, essentially, that data applicable to function F may or may not be applicable for function G. (Or, similarly, datum X may be used to qualify datum Y, but not datum Z). For example, consider a function which finds the square of a number. Nice, simple (almost trivial) function. Yet on most computers, you can give it arguments which do not have representable squares. If you were to solve this problem with static typing, I suppose you could invent some special numeric type of limited magnitude, and say that only numbers of that type could be passed to this function. Does anyone detect a note of insanity here? Just how are you supposed to verify that the result of some arbitrary computation, each stage of which has its own domain (and its own range) will generate results which are in the domain of the next relation down the line? You might as well say "Lets find the solution to all problems, rather than this one problem, because then we'll be more correct." Yeah, right. May I humbly suggest, if you really think this (static typing) is a useful approach, that you spend a little time reviewing completeness and consistency? (Ask your favorite mathematician) Who knows, maybe you'll be able to solve the knapsack problem. Finally, to Mr. Grier, who posed the rhetorical problem about trusting software in critical systems which might have latent bugs: would you really trust such software if it had never been tested? Would it make you feel safer if each type of data required seperate chunks of code, with the associated tests and branches and variant storage mechanisms? This is slightly off the topic of data polymorphism, but I'd like to point out at work it is considered good form to write code that does not branch or loop (or use recursion), as much as possible. Remember, control flow (such as branching) is just another way of representing information. With the proper primitives, you can do an incredible amount of decision making with zero branching (sort of "super-structured"). Raul Rockwell