Python Productivity Gain?

Magnus Lyck? magnus at thinkware.se
Fri Feb 20 19:51:56 CET 2004


"kbass" <kbass at midsouth.rr.com> wrote in message news:<LaBXb.8774$g95.1612 at fe3.columbus.rr.com>...
> In different articles that I have read, persons have constantly eluded to
> the productivity gains of Python. One person stated that Python's
> productivity gain was 5 to 10 times over Java in some in some cases. The
> strange thing that I have noticed is that there were no examples of this
> productivity gain (i.e., projects, programs, etc.,...).  Can someone give me
> some real life examples of productivity gains using Python as opposed other
> programming languages.

I don't think a tenfold programmer productivity increase over Java 
is typical, but there are certainly examples of significant 
productivity gains in converting to Python from some other language. 

See here for instance:
http://www.thinkware.se/cgi-bin/thinki.cgi/PythonQuotes

E.g.

"I was amazed by the amount [of] flexibility and self-awareness that
Python had. When a 20,000 line project went to approximately 3,000
lines overnight, and came out being more flexible and robust once it
had been completed, I realized I was on to something really good."

  --Glyph Lefkowitz (Developer of the Twisted network server
framework)

This 6-7-fold improvement was in going from C++ I think.

"...However, it did provide a hard measurement on the benefits of
using Python instead of C++: the lines of Python code was 10% of the
equivalent C++ code. ... From a software engineering standpoint, this
was a tremendous success. Bug counts are always proportional to the
number of lines of code, meaning that the Python version should have
10% of the bugs of the C++ version. Further, the fewer lines of code
meant that it would have a smaller and more understandable "footprint"
in the developers' minds. The Python code was arguably more
maintainable due to its improved readability and rapid edit-test cycle
(no compile and link step). Lastly, the server could also be shown to
be more robust - being entirely in Python, it was not subject to
memory-related coding errors such as null pointers, buffer
misallocation and overruns, or unfreed or doubly-freed memory..."

--Greg Stein, eShop (which was later sold to Microsoft)

Here you have a 10-fold gain, going from C++.

Another aspect of any X-fold programmer productivity improvement is 
that there is a lot more than just programming going on in a project.
If requirements capture, analysis, design, testing, documentation,
planning etc takes the same amount of time, you will still not be
able to influence the total project cost a lot.

On the other hand, using a tool like Python doesn't just influence
the programmers, but the whole project! If prototyping and coding
in general becomes significantly faster, the trade off for how much
analysis and design you should do will change. Why spend weeks at
a conference table arguing about different design alternatives if
the programmers can supply several different implementations within
a day?

The sooner a prototype can be put in the hands of the end users, the
faster mistakes in the requirements gathering will be sorted out,
and new needs will be discovered and can be weighed in before it's
too late.

The ability to play interactively with Python objects and to develop
really rapidly means that the roundtrip from end user request, to
a new prototype for her to try out, can be reduced from hours to 
minutes or from days to hours. There is no reason to even leave the 
end users computer to add and demonstrate a new or changed feature. 
All we need is there...

Testing, deployment, data conversion etc are also parts of software 
development projects that can gain a lot from having a tool like 
Python available.

Other examples of productivity boosts with python can be found here:
http://pythonology.org/success

Few mention numbers though. I guess that there are some organisations
that use the Capability Maturity Model for Software who would be able
to find useful metrics if they used Python for a project similar to
one where they had previously used Java, but a) few use CMM with such
rigor, and b) if they did, they might not want to tell! Let the
competition continue to waste their time coding Java. :) Finally, c)
organisations where CMM is popular are probably organisations where
static typing, waterfall development style and other rigid and archaic
ideas are more popular than agile methods and tools.

Still benchmarks always have a limited value.

I've looked a bit at benchmarks, such as The Great Computer Language 
Shootout and looking at lines of code there, gives much smaller 
differences than five to ten times. I compared C++ and Python, and C++
varied from 25% less to 500% more lines of code, on the average C++ 
programs were around 80% longer. Less than a twofold gain it seems...

But when we study the material in more detail, we see some relevant
things:

The more "realistic" the benchmarks are, the bigger the difference: 
For plain algorithm tests and things like "nested loops", "call a 
method", "instanciate an object" etc, there is almost no difference. 
For things like "echo client/server", "spell check", file handling 
etc, the difference is between 2.4 and 5.1 times.

I don't know how strong the Java standard library is, but several of 
the benchmarks are about reimplementing builtin things in Python, such
as sorting and random number generation. Completely meaningless! A 
real life implementation would be a much shorter, since most of the 
needed code is already in a standard library module!

For fun, I've made Python programs that achieved the same end result
without trying to use the same (meaningless) methods as the other
programs in the benchmark, and they are often 10 times shorter. 
Sometimes they are also much faster and scalable. 

There are three big reasons that Python programs are typically short 
and easy to read.
 * The Python syntax and data types are at a higher level of 
   abstraction, and don't have a lot of noise. It's also designed 
   with the objective of making it easy to do the right thing, rather 
   than making it difficult to do the wrong thing.
 * The dynamic nature of Python makes it easy to write very flexible
   code, and avoid a lot of code redundancy and twisting that is 
   common as you have to fight against the limitations of more static 
   and low level languages.
 * Python's standard library is rich and reasonably easy to use.

In addition to that, the absence of compile and link steps in Python
makes development much faster than languages like C++. I've worked
in large C++ projects where building major applications could take
an hour due to the extensive dependencies. In Python this is a non-
issue. I don't know enough about Java development to compare with 
that.

Since Python programs are shorter and easier to understand, and
faster to write than programs written in most other languages, it's
usually viable to change or rewrite code which is slow or otherwise
non-optimal, while it's common in projects using other languages
that code which is known to be bad is kept because it's too costly
to fix it.

Anyway, if you try Python in some project, I geuss your will form
an educated opinion. I'm sure there is no one objective truth about
this. Different people have different preferences, and different
languages have different sweetspots. If you are writing drivers for
hardware, or encryption code, Python is probably not main language,
but it might still be very useful for various tools and one shot
hacks that you do while you develop the "real" software in some 
other language.

Some people think Ruby is "purer" and "prettier" than Python. 
Personally, I find the Perl-like features, such as various #@$%
etc and mixing regular expressions in the syntax of the language
rather awkward.



More information about the Python-list mailing list