python without OO

Francis Girard francis.girard at free.fr
Wed Jan 26 14:39:20 EST 2005


Le mercredi 26 Janvier 2005 02:43, Jeff Shannon a écrit :

> In statically typed languages like C++ and Java, inheritance trees are
> necessary so that you can appropriately categorize objects by their
> type.  Since you must explicitly declare what type is to be used
> where, you may need fine granularity of expressing what type a given
> object is, which requires complex inheritance trees.  In Python, an
> object is whatever type it acts like -- behavior is more important
> than declared type, so there's no value to having a huge assortment of
> potential types.  Deep inheritance trees only happen when people are
> migrating from Java. ;)
>
> Jeff Shannon
> Technician/Programmer
> Credit International

These lines precisely express my thoughts. Most of the difficulties in OO in 
Java/C++ comes from the all mighty goal of preserving type safety. Type 
safety is certainly a very desirable goal but it, sometimes, leads to very 
complex code only to achieve it. The prize is just too high. The design 
patterns that were supposed to save time through high code reuse oftenly 
becomes a maintenance nightmare. Something that no one in the company can 
understand except a few. Instead of trying to fix some domain specific code, 
you end up trying to fix a supposedly highly reusable code that, oh well, you 
have to adapt. This is espeacially true if the system had been designed by a 
big OO-design-patterns enthusiastic programmer geek.

I am not saying that design patterns are bad. I think that they are an 
invaluable gift to OO. I'm only saying that they have indeed a perniciuous 
and pervert effect in the real world industry. People become religious about 
it and forget to think about a simple solution ...

Being dynamically typed, these kind monster patterns are much less probable. 
And the Python philosophy and culture is the very contrary to that trend.

I've been involved in C++/Java projects for the last 8 years. The first time I 
met Python, I've been frigthen by its lack of static type safety. But over 
the time, I've been convinced by seeing clean Python code over and over 
again. In the end, I could appreciate that being simple leads the way to less 
bugs, which type safety was supposed to prevent ... Coming from the C++ 
community, Python had been just like fresh air. It changed me from the 
nightmare derscribed in that discussion thread. When I think that comapnies 
pay big money for these kind of monsters after having seen a few ppt slides 
about it, it makes me shiver.

Regards,

Francis Girard
FRANCE





More information about the Python-list mailing list