[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Apr 10 23:20:14 2000 
Subject:Re: List of Possible Poplog Projects 
From:Vesa A Norrman 
Volume-ID:1000410.08 

steve@watchfield.com writes:

> >>  I've got used to using typed languages, and I no see no advantage
> >>  whatever in pop11's untyped variables. (Ditto for lisp, incidentally.)
> >>
> >  > If there are any advantages, someone remind me.
> >
> >I entirely agree.
> 
> Well, since you both asked here is my favourite example.  Let us suppose
> we want to write a generalisation of -pdcomp- as follows.
> 
>      define pdcomp_list( L );    ;;; takes a list of funcs
>          applist(% L, apply %)
>      enddefine;

I didn't understand what that program should do but I guess if you want
that you really need a dynamically typed language.

> public int indexOf(int ch)
> 
> 	Returns the index within this string of the first
> 	occurrence of the specified character. If a character with
> 	value ch occurs in the character sequence represented by
> 	this String object, then the index of the first such occurrence
> 	is returned -- that is, the smallest value k such that:
> 
> 		this.charAt(k) == ch
>                      
> 
> 	is true. If no such character occurs in this string, then
> 	-1 is returned.
> 
> Just in case it is not obvious why this is a poor interface, let us
> suppose that we forgot to check the -1 result when we were checking
> out the successor character.  We might write something daft like this ...
> 
>      s[ max( s.indexOf( ch ) + 1, s.length ) ]
> 
> So, to spell out the entire argument, strong typing is a restriction on
> the language that (despite undoubted benefits) occasionally leads to
> awkward situations.  The temptation to fudge the solution remains
> irresistible to even very good language designers, such as the Java folks,
> and makes the relevant code more vulnerable to error than the dynamically
> typed equivalent.  In these cases _both_ clarity and safety are compromised.
> In addition, the restrictions entailed by strong typing can be very
> problematic when working with collections of cooperating functions.
> And although the strongly typed languages have won hands-down in terms of
> popularity, there is nevertheless a considerable demand for dynamically
> typed languages.
> 
> Hey, you did ask.

You can't blame strong typing for that kind of design. I think it's
because otherwise you would need to return an object which contained
the character and the errorcode. That would be rather awkward.
Also, Java inherits some practices from C.

Standard ML (which is a strongly type language) has a function of type

instream -> elem option

which reads a character from input stream. If there are characters
in stream it returns SOME e; otherwise it returns NONE. I think is this
is a good interface.

I think a strong type system is very usefull, because it allows
compiler to find many bugs during the compilation.

> >  > (And the ability to
> >>  use a variable without declaring it is a DISadvantage, not an advantage.)
> >
> >Absolutely. As an undergraduate learning pop11, I switched this off as soon
> >as I knew how. As a more experienced programmer, I'm, er, "surprised" that
> >such a rich and fertile source of novice bugs is touted as a feature :-)))

I think the ability to use a variable without declaring it's type is
an advandage because it makes source code smaller. However, I don't have much
experience in pop11 so I'm just speaking generally.
VEsa