Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!zazen!uwvax!daffy!khan.cs.wisc.edu!quale From: quale@khan.cs.wisc.edu (Douglas E. Quale) Newsgroups: comp.lang.misc Subject: Re: Run-time Type Errors in Smalltalk Message-ID: <1991May13.061520.11992@daffy.cs.wisc.edu> Date: 13 May 91 06:15:20 GMT References: <2604@calmasd.Prime.COM> <1991May9.023313.28308@tkou02.enet.dec.com> Sender: news@daffy.cs.wisc.edu (The News) Organization: University of Wisconsin -- Madison Lines: 51 In article <1991May9.023313.28308@tkou02.enet.dec.com> diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) writes: >When mismatches are detected (which can benefit greatly from mechanical >assistance or compilers), they can be inspected manually to see if they are >really errors, or which part has the errors. This is far better than skipping >half of them and letting 10% or 90% of the other half remain undetected. >-- >Norman Diamond diamond@tkov50.enet.dec.com >If this were the company's opinion, I wouldn't be allowed to post it. 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 all that points one way or the other. I think I understand why static typing devotees believe that static typing is safer than dynamic typing, but I think they're mistaken. In considering the evidence presented by both sides I show my bias by giving greater weight to those who have actually used dynamically typed languages. Simply stated, almost everyone experienced in writing in dynamic languages also has experience with statically typed languages. The reverse is often (usually?) not the case. Two particulars: Dynamic typing makes program components easier to test interactively in isolation; the components get tested again together. You may say you do all these tests in your statically typed language even though it's very inconvenient. I ask you, does everyone? In either case I appreciate the great saving in time and effort that an interpreter + compiler provide. (Some statically typed languages provide interactive environments. The only examples that I'm familiar with are examples of type inferencing systems much more advanced than Pascal/C/Ada type systems. Many of these are not as convenient to use as a dynamically typed system -- see for instance a thread in comp.lang.functional about SML.) Static type systems can actually be MUCH LESS SAFE than dynamic type systems. I mention this only because perhaps some folks haven't considered it. This is often a problem when a primitive static type system attempts to emulate dynamic typing. A specific example is provided by the X Toolkit Intrisics. To get information from a widget you use a call that looks like this: XtVaGetValues(widget, XtNwidth, &width, XtNheight, &height, NULL); Unfortunately width and height are type XtArgVal which is a union which completely defeats any typechecking. The correct type is Dimension, should I instead use int I get no help from the compiler, and my code has a type error. This kind of type error CANNOT occur in a dynamically typed language. -- Doug Quale quale@khan.cs.wisc.edu