Re: [vos-d] [OFF] typing

2006-03-13 Thread Peter Amstutz

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I started writing a long post about this, and deleted it because I don't 
want to wade too far into this flame war.  I'd just like to point out 
that, ultimately, language design is a trade-off.


If you are using a runtime-typed language, you are gambling that the 
upfront time saved on coding will be greater than the possible increase in 
time spent debugging.


If you are using a statically-typed language, you are spending more time 
fighting with the compiler and/or writing out class hierarchies, but 
gambling that the extra upfront coding time will result in less time spent 
debugging.


I would say that as the size of a project grows, the amount of time typing 
in code increases linearly, but the amount of potential debugging 
increasing geometrically, as the number of interacting 
statements/functions/classes/modules increases.  Thus, techniques that 
reduce debugging time are going to be proportionally more effective than 
techniques that reduce upfront design time.


That said, there's probably a crossing-over point, where projects below 
some size are better served with a dynamic type system, and projects above 
that size are better server with a static type system.  The point could 
also be made that certain dynamically typed languages are more powerful 
(they can acomplish more per line of code) which raises the bar.


To some extent given the original discussion this is even a false 
dichotomy, because people often embed dynamic typing systems into 
statically typed languages (i.e. VOS metaobjects) and furthermore 
langauges like C# have an extensive reflection API which allows you to do 
things like invoke methods with a certain name, signature or attribute 
regardless of its actual class type.


So while you can do dynamic type checking in a mostly static language, 
typically you can't do static type checking in a dynamic langauge.  In the 
end this seems less powerful to me.


- - Pete

(or maybe I just don't like Python's force indentation very much :-)

On Mon, 13 Mar 2006, Hugh Perkins wrote:


Hi Lalo,

Yes, you're right that dynamic typing is very cool.

I guess the thing that I find tricky in Python is that it is possible to
accidentally add unintended properties to a class by misspelling the
intended one, and sometimes it's tricky to catch this.  For example (my
Python syntax might be a little rusty..):

class MyClass():
  def __constructor__(self, name):
 self.name = name

  def PrintName(self):
 print "My name is " + self.myname

myobject = new MyClass("Tom")
myobject.PrintName()

gives:
C:\> python test.py

My name is

C:\>

... because we wrote self.myname instead of self.name.

Obviously in this somewhat trivial example it's easy to debug, but the point
is that this introduces logical errors into the code, that are never caught
by the interpeter itself, only by seeing that the results are not what we
want.



[   Peter Amstutz   ][ [EMAIL PROTECTED] ][ [EMAIL PROTECTED]  ]
[Lead Programmer][Interreality Project][Virtual Reality for the Internet]
[ VOS: Next Generation Internet Communication][ http://interreality.org ]
[ http://interreality.org/~tetron ][ pgpkey:  pgpkeys.mit.edu  18C21DF7 ]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEFmFNaeHUyhjCHfcRAsR6AJ9QEy0hFy7YE0dprkdx6kKvn+M5RQCeKALg
xrgxyJ4n8wPR2ZrzzuK6avs=
=gZ9p
-END PGP SIGNATURE-


___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d


Re: [vos-d] [OFF] typing

2006-03-13 Thread Reed Hedges
On Mon, Mar 13, 2006 at 07:14:12PM +0800, Hugh Perkins wrote:
> Lalo,
> 
> What are your thoughts on Duck Typing? http://boo.codehaus.org/Duck+Typing

Isn't this mostly the same as message-passing object oriented systems
(Smalltalk, etc.)

Reed


___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d


Re: [vos-d] [OFF] typing

2006-03-13 Thread Hugh Perkins
Lalo,
 
What are your thoughts on Duck Typing? http://boo.codehaus.org/Duck+Typing 
___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d


Re: [vos-d] [OFF] typing

2006-03-13 Thread Hugh Perkins
Hi Lalo,
 
Yes, you're right that dynamic typing is very cool.
 
I guess the thing that I find tricky in Python is that it is possible to accidentally add unintended properties to a class by misspelling the intended one, and sometimes it's tricky to catch this.  For example (my Python syntax might be a little rusty..):

 
class MyClass():
   def __constructor__(self, name):  self.name = name
 
   def PrintName(self):
  print "My name is " + self.myname
 
myobject = new MyClass("Tom")
myobject.PrintName()
 
gives:
C:\> python test.py
 
My name is
 
C:\>
 
... because we wrote self.myname instead of self.name.
 
Obviously in this somewhat trivial example it's easy to debug, but the point is that this introduces logical errors into the code, that are never caught by the interpeter itself, only by seeing that the results are not what we want.

___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d