is python Object oriented??

Michael Torrie torriem at gmail.com
Sat Jan 31 21:10:40 EST 2009


thmpsn.m.k at gmail.com wrote:
> More interestingly, though, most compilers translate C and C++ code to
> assembler first. Does that mean that you can do object-oriented
> programming, generic programming, and procedural programming in
> assembler?
>
> Answer: No, but you can probably -- very clumsily -- fake them.)

This is getting quite far off the topic, but of course you can, and it's
not faking anything.  This should be obvious.

You can certainly do OO programming in C, which is a glorified
assembler.  For example, the gobject system defines a complete
object-oriented system with classes, inheritance, polymorphism,
encapuslation.  It uses structures for encapsulating the data and call
tables for virtual methods (to use a c++ parlance).  It's such a well
defined object model that you can, with gtkmm, even extend a c-based
gobject class with C++!  Of course you can also extend gobject-based C
classes with python as well using PyBank to import them.

Back when assembly was still somewhat in vogue I read a book on
programming assembly in an object-oriented manner.  So of course you
can.   Yes it can be clumsy without syntactic sugar.  If you set up call
tables, you can handle polymorphism.  How would this be faking it?  By
your definition C++ is faking it since C++ compiles to assembly.  In the
early days, C++ was first implemented as a preprocessor that emitted
straight C code.  And I guess python fakes it since the python
interpreter is implemented in C compiled to ASM.

Maybe the terminology would be less confusing if we considered the
terms, object-oriented programming, object-oriented languages,
object-oriented systems.  Any language can be used for the first.
Python, Java, C++ can be defined by the second, and things like Python
(the runtime environment), .NET, JVM, Parrot, can be defined by the last
term.  Fair enough?

Python is certainly an object-oriented language, and implements a
complete object-oriented system.  Python can support coding in an
object-oriented methodology, or you can code traditionally while still
taking advantage of the complete OO system.



More information about the Python-list mailing list