Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!umich!vela!m.cs.uiuc.edu!cs.uiuc.EDU!johnson From: johnson@cs.uiuc.EDU (Ralph Johnson) Newsgroups: comp.lang.misc Subject: Re: Static typing: the OOP seatbelt Message-ID: <1991Apr1.163129.28975@m.cs.uiuc.edu> Date: 1 Apr 91 16:31:29 GMT References: <14160@life.ai.mit.edu> <1991Mar25.201620.5839@cua.cary.ibm.com> <27F11D7B.6309@tct.uucp> <49229@nigel.ee.udel.edu> Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager)) Reply-To: johnson@cs.uiuc.EDU (Ralph Johnson) Organization: University of Illinois Lines: 33 Nntp-Posting-Host: m.cs.uiuc.edu In article <49229@nigel.ee.udel.edu>, carroll@cis.udel.edu (Mark Carroll) writes: |> |> Any typing error that would be trapped in a staticly typed language |> can be captured in a dynamically typed languages using dataflow |> analysis. If the error can't be caught with dataflow, then either |> the program would be written differently in the static language (in |> which case, the same safe version could be written with the dynamic |> typed language), or the staticly typed language would have a kludged |> dynamic typer, in which case the static language would be as subject |> to error as the dynamic. |> Any proof of this claim? I don't believe it. This claim seems to be the same as saying that dataflow analysis can always determine the types of variables and expressions. This is not true. Given a powerful enough type system, type inference is undecideable. In general, it is easier to decide whether a program is legally typed than to discover a legal typing for it. Determining whether a program will have a typing error often requires finding program invariants. Dynamic typing means that programmers don't have to write down these invariants, which is why languages with dynamic typing are easier to program in, at least for medium-scale programming. For the record, I am a Smalltalk fan, and have been working at developing a type system and a type inference system for it. Type inference is basically the same as dataflow anlysis. Type inference is MUCH harder than type checking. It has lots of advantages, to be sure. However, I don't believe that "any typing error" that would be detected by a type checker could be detected by a type inference system, i.e. by dataflow analysis. Ralph Johnson -- University of Illinois at Urbana-Champaign