Correct type for a simple "bag of attributes" namespace object

Roy Smith roy at panix.com
Sun Aug 3 20:59:17 EDT 2014


In article <53ded02e$0$29980$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> Marko Rauhamaa wrote:
> 
> > I've reached a point where I think classes are a superfluous OO concept.
> > You only need objects.
> 
> I don't know whether "superfluous" is correct, but they certainly are
> *optional*. There are at least two types of object oriented programming:
> class-bases, and prototype-based. Java, Python, Ruby, etc. are all
> class-based. The only example of a prototype-based OOP language I know of
> is Javascript, and even that has recently gained the ability to define
> classes.
> 
> I don't know enough about prototyped OOP to really give a definitive answer,
> but I believe that the popularity of class-based OOP is because there is a
> huge body of theory on types, which makes it easier for compiler designers
> to reason about classes than prototypes. For example, if Haskell introduces
> OOP (and it may already have, I don't know) I would expect it to be
> class-based. Also, the first OOP languages (Simula and, especially,
> Smalltalk) are class-based, and people tend to copy what's been done before
> and what they're familiar with.

The first code I ever saw which had any OO concepts was the Unix kernel 
I/O drivers.  The whole thing was written in C.  It essentially 
implemented something we would recognize today as static class 
inheritance with polymorphic method dispatch.

Each driver was required to implement a number of functions (read, 
write, open, etc), with specified signatures and contracts.  
Effectively, the all subclassed a (mythical) BaseIODriver.  There was a 
big table where the rows were the different drivers (indexed by major 
device number), and the columns were the different methods.  That was in 
the early 70s.



More information about the Python-list mailing list