Could Python supplant Java?

Stuart D. Gathman stuart at bmsi.com
Wed Aug 21 21:20:26 EDT 2002


On Wed, 21 Aug 2002 11:25:31 -0400, Mark McEahern wrote:


> In other words, you don't care whether it's a file, you care whether you
> can read() it?  That makes sense to me.

This is exactly what Java interfaces do for you.  If you declare a
variable as "FileLike", then any object, regardless of derivation, can be
directly assigned to it provided it implements the FileLike interface.

An improvement on this is the "signatures" extension in GNU C++.  With
Java, all classes have to be specifically stamped with the interface
before they can be used. (This can be done with a library class be
extending or embedding it, then implementing the interface.  But that is a
lot of trouble.)  With a signature, any object that has the methods in the
signature can be assigned to the variable - regardless of how the object
was declared.  The compiler essentially creates adapter classes under the
covers when necessary as mentioned parenthetically above - saving you the
trouble.


-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.



More information about the Python-list mailing list