[Haskell] pros and cons of static typing and side effects ?

Hamilton Richards ham at cs.utexas.edu
Thu Aug 11 15:40:25 EDT 2005


At 10:40 PM +0200 2005/8/10, mt wrote:
>... Languages with
>static typing would be more suitable if programs were something you thought
>of in advance, and then merely translated into code. But that's not how
>programs get written.

Well, that is actually how lots of programs do get written.

For software that is experimental and exploratory, whose code 
undergoes continual change and whose only users are the code's 
authors, static typing is arguably a dispensable nuisance. A type 
error that pops up during execution is probably no more inconvenient 
than one that's caught by static type checking. That's why Lisp is 
popular for AI work.

On the other hand, for code that is intended for wide distribution, 
static typing is extremely useful. When a user swipes his card in an 
ATM, you don't want the machine's response to be "Sorry, type error."
    A successful static type check amounts to a partial correctness 
proof, i.e., a guarantee that a large class of possible errors will 
not occur during execution. That guarantee is worth some 
inconvenience-- or would be, if static typing were in fact 
inconvenient.
    I'd argue, however, that for software that's being written for a 
specified purpose, and which therefore has a well defined 
specification, static type checking is a definite convenience-- it 
automates some of the reasoning that responsible programmers are 
obliged to undertake in any case.

Of course I have to concede that much software that's sold to 
customers is not actually "thought of in advance", but is developed 
haphazardly, with inordinate effort expended on "debugging". This 
regrettable practice no doubt bears much of the blame for the 
deplorable state of the software industry, which is the only one I 
know of whose products are routinely sold with a disclaimer of all 
responsibility for their quality.

Regards,

--Ham

-- 
------------------------------------------------------------------
Hamilton Richards, PhD           Department of Computer Sciences
Senior Lecturer (retired)        The University of Texas at Austin
ham at cs.utexas.edu                hrichrds at swbell.net
http://www.cs.utexas.edu/users/ham/richards
------------------------------------------------------------------


More information about the Haskell mailing list