Python Productivity over C++

Nick nick at spam_me_not_videosystem.co.uk
Sun Jun 11 06:16:24 EDT 2000


> >>I have read in several places productivity claims of 5 to 10 times over
> >>'C' and "C++". I would like to ask for some feedback from "C++"
> >>programmers who have moved to Python as to whether these estimates are
> >>realistic.

It depends on the problem domain. I write text parsing/generation code and I
would probably say that 5-10 times increase in productivity is almost fair, once
you take into account the higher level data structures, libraries and lack of
obfusticated syntax. I have written equivalent code in C before I learnt Python
and it was horrendous! You could blame my programming style ;-) but writing
parsers in C, even with Lex & Yacc is a pain. But Python is geared towards
pragmatic programming and I do find that.

> >>2. How long did you use Python before you achieved increased
> >>productivity ?

I've been a user for about 6 months. I found productivity gains immediaitely and
am getting better! Its getting out of the C++ mindset and into the Python data
structure one that takes time! That and learning the Python libraries eg.
sys,os,os.path,string,re etc. You can write much more reusable, unit testable
code in Python more easily. I think the lack of typing really aids reusablity
and code productivity.

> When you write a class in C++ and you want to do it *well*, you have to
> think about a horrible amount of stuff; constructor, destructor, copy
> constructor, assignment operator, possibly other operators, public, private,
> protected. Without the STL you'll have to do lots of manual memory
> management as well; reallocating arrays, etc. If you want to write a
> generic class there's a whole set of extra things to consider.
> I found that this took a long time in C++, while whipping up a decent
> class in Python is a piece of cake in comparison. Even generic Python
> classes.
> It's perhaps just a difference in philosophies as well; C++ is a statically
> typed language and its proponents put a lot of emphasis on this kind of
> correctness. In Python you might come up with lots of correctness rules
> as well, but people don't, as the whole approach is different. People
> rarely care about things like public/private, even. This also means a lack
> of getters/setters in many cases; those will only be created if they
> are deemed necessary. This means encapsulation can be broken easily,
> but Python programmers don't care about this so much -- in practice often
> it is more of a problem to strictly preserve encapsulation (and type safety)
> than it is to fix any problems when and if they arise.

I agree. I was thinking about this over the weekend and I think the main reason
why Python is more productive is the syntax. Constructors, overloading, strong
typing, templates, blah, blah in C++. You have to think about your implementaion
far more in C++ than you do with Python, ie. do I use templates or classes etc.
There's more typing (on the keyboard!!) to be done in C++!!! You just get on
with it in Python! The main penalty is speed of execution which I can live with
know how painlessly I wrote the script!

Cheers,
Nick.







More information about the Python-list mailing list