Xref: utzoo comp.lang.misc:6962 comp.object:2801 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uwm.edu!bionet!agate!stanford.edu!neon.Stanford.EDU!hoelzle From: hoelzle@neon.Stanford.EDU (Urs Hoelzle) Newsgroups: comp.lang.misc,comp.object Subject: Re: blip [Re: Dynamic typing -- To Have and Have Not Message-ID: <1991Mar20.214231.3411@neon.Stanford.EDU> Date: 20 Mar 91 21:42:31 GMT Article-I.D.: neon.1991Mar20.214231.3411 References: <22032@yunexus.YorkU.CA> <11820:Mar1923:59:3591@kramden.acf.nyu.edu> <19MAR91.22493670@uc780.umd.edu> <18271:Mar2013:19:1091@kramden.acf.nyu.edu> Organization: Computer Science Department, Stanford University, Ca , USA Lines: 57 brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >> What I have claimed is that I can solve problems faster >> in a dynamically typed language than in a statically typed language. >I firmly believe that the speed of problem-solving in any language is >based mostly, if not almost entirely, on how much already-written code >you can apply to the problem. I absolutely agree. >There is no reason beyond religion to >believe that dynamic typing helps reusability. I absolutely disagree: The maximum reusability occurs in a system where every piece of functionality (you may call this "algorithm") is specified EXACTLY ONCE (i.e. there is no redundancy). This requires that every piece of code depends ONLY on the abstract interface of its arguments: for example, a sort routine would work on every collection whose elements understand < and =. Current type systems are too restricted to allow this, and so you end up duplicating functionality in many cases. However, in dynamically-typed languages such as Self you *can* write e.g. a sort routine which works for *every* kind of object which understands the comparison protocol. Thus, if you design your system correctly, ideal reusability can be achieved *today* in an untyped language but not in any typed language I know of. It can be achieved partially in languages with genericity. But only partially: as soon as you also use inheritance, you get lots of problems with static type systems. (For example, if T1 is a subtype of T, "collection of T1" is *not* a subtype of "collection of T".) So you have to give up on the "no duplication" goal with today's staically-typed languages and thus reduce reusability. [Many papers have been written on this, so I'll omit the details here. Pointers available on request.] In summary, the statement "typing helps reusability" has nothing to do with religious beliefs - it's a fact. Note that I'm not saying that the same reusability couldn't be achieved with "mostly-typed" languages, i.e. languages which use types for what they are good at (detecting trivial errors) but still allow you to use the flexibility of dynamic typing where it is required. -Urs -- ------------------------------------------------------------------------------ Urs Hoelzle hoelzle@cs.stanford.EDU Center for Integrated Systems, CIS 42, Stanford University, Stanford, CA 94305