🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #3404

Re: Dynamic typing (part 3)

#3404
From: David Gudeman
Date: Mon, 08 Apr 1991 00:41
71 lines
3763 bytes
In article  <28673@dime.cs.umass.edu> victor yodaiken writes:
]In article <1APR91.23564447@uc780.umd.edu> cs450a03@uc780.umd.edu writes:
]...dynamic language[s]... better model human
]>thought mechanisms as exemplified by thousands of years of
]>mathematical development).
]>
]
]People keep saying this, but it just ain't so. Type declarations are
]an integral part of mathematics...
]Maybe I'm missing an essential difference
]between these type declarations, and the declarations of programming
]languages. If so, I'd be happy if someone could explain.

OK, try this.  In mathematics you don't have to describe the types of
objects unless the type is important.  In statically typed languages,
you have to declare the type whether it has any relevance or not (or
fix it at compile time whether it is really knowable or not).  In
mathematics or dynamically typed languages you can describe the
concept of a set or a sequence, and operations over those data
structures, without refering to the "type" of elements.  For example
in math you could say

  If f is a function and s is a sequence, then map(f,s) is the
  sequence t such that for all i . t[i] = f(s[i]).

In a Icon (a dynamically typed language) you could define

  procedure map(f,s)
  local t,i
  t := list(*s)
  every i := 1 to *s do t[i] := f(s[i])
  return t
  end

Try to write this function in a statically typed language so that it
has all the generality of the math and Icon versions.  (Actually, the
math version works for infinite sequences and the Icon one doesn't.
There are languages that fix that...)  No, forget the challenge.
Someone is sure to post a solution (or near solution) using some
baroque system of static declarations from Ada or some wierd C trick
(I can think of one...).  The point is that even if you can sort of do
it in these languages, it is obvious that the Icon version is much
closer to the mathematical (I say "reasonable" or "natural") way of
doing it.

Furthermore, when you do use something like a type declaration in
mathematics, it is to disambiguate or add clarify, and the nature of
the declarations reflects that.  In statically typed programming
languages the purpose of the types is to let the compiler generate
better code, and the nature of the declarations reflects that.  For
example, you cannot simply declare something as a "number", you have
to decide whether you want it represented in floating point format or
integer, and what size you want.  You can't declare that something is
a set, you have to implement a set using fixed-size memory blocks.

I just depends on what you want in a programming language.  If you
think that programming languages should always give fairly transparent
compilation, or are willing to go to a great deal of extra work for a
few extra cycles, then you won't be too happy with dynamic typing.
But it is just ridiculous to claim that static typing is more natural
than dynamic typing -- I am talking here about static typing in the
sense that _every_ expression has to be give a fixed type of the form
found in programming languages.

I only have to show one example of "dynamic typing" in mathematics to
show that mathematics is not "statically typed" in the universal sense
of statically typed programming languages (and I did so above).
--
					David Gudeman
gudeman@cs.arizona.edu
noao!arizona!gudeman
Technical Details
Message-ID: <1593@optima.cs.arizona.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!asuvax!noao!arizona!gudeman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!asuvax!noao!arizona!gudeman
From: gudeman@cs.arizona.edu (David Gudeman)
Newsgroups: comp.lang.misc
Subject: Re: Dynamic typing (part 3)
Message-ID: <1593@optima.cs.arizona.edu>
Date: 8 Apr 91 00:41:22 GMT
Sender: news@cs.arizona.edu
Lines: 71