Is Python overhyped (just like Java)?

Anand B Pillai abpillai at lycos.com
Mon Mar 31 06:33:13 EST 2003


Truly wonderful post from Alex ...

Why would anyone use Python ? Well, first of all it is a true
object-oriented language in the spirit of Smalltalk/Java whereas
C++ is not one. It has a clean syntax and comes with many pre-built
libraries, most of them written in C(CPython) or Java(Jython). It
is a higher-level programming language when compared to C++, as Alex
pointed out. 

 First of all I dont agree that there is any 'hype' associated with
python. Java hype was true and real, because it was a language
promoted
by a single company, a monolith as a panacea for all the problems
caused
by programming on M$ tools. Its single idea was to offer stiff
competition
to M$ coffers and to put Sun's grip on the developer's desktops. Alas,
it
realized far less than the expectations it raised, as we all know. 

 Python on the other hand is a free language developed by a group of 
programmers based on the idea of software freedom. It is not promoted
by
any company AFAIK and it does not have any grand designs like Java.
Also,
python has been around for some time, far more than Java has been.
There
is no hype and no need for one as a matter of fact.

 I learned python quite accidentally. I need to write many small
scripts
for my day-to-day routine programming tasks. I found shell too awkward
for the task and too time-consuming. I tried my hands at batch
programming
but it's capabilities are limited as anyone who has ever fired up a 
"command" shell with a "cmd /C" and attempted those nifty shell tricks
that M$ has integrated with their Windoze knows ...;-). The next
natural
step was 'awk' but to me it felt like Shell served with "C" fries !  I
had heard about python quite some time back, but never actually got 
swallowed by it. I went to the python website and read guido's amazing
tutorial on python. That got me hook, line and sinker and I was a prey
to the python language ever since. Now I find scripting child's play
what
with the excellent capabilities that python offers. Try a few scripts
using
"sys" and '"os" and you will know ... (wink).

  The single biggest advantage of python is SPEED. You can map your
problem space to solution space with 10% of the time you need to
prototype
in C++, in python(Probably lesser, but this question is better
answered
by professional python programmers). C++ burdens the programmer with
mundane
tasks like freeing memory, declaring headers, writing macros to feed
the preprocessor, the list is endless. 80% of the time to program a
C++ project
is taken in deciding on the code modules, preparing the header files
and
the directory structure, deciding which symbols to be
exposed(exported).
The actual productivity time  declines because of this. For example,
the
last three projects I did for my company was for fixing performance
bottle-
necks in their application written in C++. The programmer sometimes
gets
bogged down in umpteen fine details like I mentioned, that he doesnt
actually
profile the code. This  causes performance bottlenecks, the customer
complains
and once again the task goes to another programmer to find and fix the
time-consuming code portions. The actual cost goes up in fact, rather,
for
the company, as well as the consumer.

    Python works well for tasks like text processing, XML parsing.
There
is excellent support for regular expressions in the form of the 're'
module.
The list is extensive, and most of them are avaialable on all
platforms that
python is available. 

    Python makes programming fun. If programming in C++ is fun then
doing it
in python will be more so. If programming in C++ makes you weary as it
does me
:-(, all the more reason to jump onto the python bandwagon :-)

  Learn python today and you will agree that it was time well spent.

Regards


Anand Pillai
http://members.fortunecity.com/anandpillai      

Alex Martelli <aleax at aleax.it> wrote in message news:<omqha.31133$Jg1.677484 at news1.tin.it>...
> Ajay na wrote:
> 
> > Can some-one please explain why one would want to use Python?
> 
> One word: *PRODUCTIVITY*.
> 
> > What is wrong with C++?
> 
> One word: *COMPLEXITY*.
> 
> 
> > In my opinion, the problem with C++ has nothing to with the language
> > semantics.  The problem is that when people are confronted with a powerful
> > language like C++, they tend to want to optimize everything to death.
> > That's when they get themselves in trouble.
> 
> You're over-generalizing.  Not all users of C++ are so naive as to
> have failed to read Knuth -- "Premature optimization is the root of
> all evil in programming".  But the point is -- by choosing a lower
> level language, like C++, at the start of your project, rather than
> a higher level one, like Python, you ARE optimizing WAY prematurely.
> 
> 
> > Those who use Python know they are sacrificing a lot in terms of memory
> > and
> > speed.  But if they took the same attitude toward C++, they can actually
> > get a lot of flexibility, code reuse, simplicity, and all the other
> > benefits of
> > OO programming at over half the cost of using Python!  The problem is that
> 
> Whaddya mean "over half the cost"?
> 
> I'm putting the final touches on a talk I'll give to PythonUK next
> week (it's held together with the ACCU conference) on "Python for
> C++ and Java programmers".  One example I give is a task for which
> C++ is quite suited, with its standard library -- reading a text file,
> breaking it into whitespace-separated 'words', building an index from
> each word to the line numbers on which it appears, and showing the
> index with words in alphabetical order, one per line, each followed
> by the line numbers on which it appears.
> 
> Thanks to the excellent support given for these tasks by the standard
> library, the C++ source is ONLY twice as big as the Python source for
> the same job (a more usual ratio is around 5:1).  This holds for both
> the simplest versions, and the slightly more complicated ones with
> somewhat better optimization.  The runtimes on my box (Linux Mandrake
> 9.0, gcc 3.1, Python 2.3) are, when the programs are run on the 4.4 MB
> of the "King James Bible" in plain ASCII text: 17.4 seconds for the
> simplest C++, going down to 15 with optimizations; 11.2 seconds for the
> simplest Python, going down to 8.1 with optimizations (CPU times are
> in very similar ratios).  Of course, this basically reflects the
> excellence of Python's intrinsics (dictionaries, lists, strings)
> versus the lesser quality of C++'s library implementation (maps,
> vectors, strings) -- with different implementations, you may see
> different ratios.
> 
> But what won't change is, the Python program IS smaller, because
> Python it's a higher-level language -- AND each statement is
> intrinsically cleaner and simpler, so the development time ratio,
> for programmers who have perfectly mastered both languages and
> the respective standard libraries, is even more extreme than the
> ratio in program sizes.  The simplest and most flexible C++ you
> can write is still way bigger, more complicated, and less flexible
> than the most refined and optimized Python code it may make sense
> to write -- it's as simple as this.  For tasks to which Python is
> extremely well suited (text processing of all kinds, including XML
> parsing, for example), you may ALSO get better running time than
> C++ with the standard library would give you -- in general, C++
> lets you develop faster code, but oh what a price in terms of
> productivity you pay for that!
> 
> And the funniest thing is, there IS no need to pay that price --
> 90% of your program's runtime is likely to be taken up by 10%
> of your program's source code, or some such ratio.  By writing
> Python first, you'll often get an application with acceptable
> performance; if not, you profile it, find out the hot-spots,
> optimize those in Python terms, and if that's still not enough,
> it's EASY to recode the hot-spots in faster ways while still
> leaving MOST of your application in Python.  There are many
> ways to do such recoding (even without counting the still
> experimental 'psyco' selective just-in-time optimizer), and
> among them are ways to integrate C++, such as SciPy's "weave"
> and the Boost Python Library (if you don't know Boost, DO
> give it a look -- it WILL increase your C++ productivity, and
> not just by easing integration of C++ to Python, either).
> 
> > people who don't understand C++, are afraid to use the 'virtual' features
> > of
> > that language because it's 'too expensive'.  But that's stupid...because
> > Python's 'virtualness' is even more expensive!
> 
> It's quite inconsiderate of you to imply that Python users are
> "people who don't understand C++", when among those users are
> people like Andrew Koenig (author of "Ruminations on C++" and
> other great C++ books, as well as a towering figure of C++
> development -- the algorithm for name lookup in the C++ language
> is called "Koenig lookup" because HE developed it...!), Bruce
> Eckel (author of best-sellers "Thinking in C++" and "Thinking
> in Java"), and so many others whose C++ competence is in all
> likelihood AT LEAST as good as yours.
> 
> 
> > Nope...I'm not trolling...I want someone to give a solid and intelligent
> > argument about why I should switch from C++ to Python!
> 
> You shouldn't *SWITCH*!  If you hadn't already made the huge
> investment to master all the complexity of C++, it might be
> best to avoid it -- but, if you HAVE made it, count it as a
> "sunk cost", as I do, and see how best to leverage it.  Learn
> Python (a trivial investment compared to learning C++), and
> use BOTH Python and C++ in your development.  You'll find that
> Python gives you extremely high productivity and flexibility,
> letting you prototype, experiment, refactor whole architectures
> from the inside out and back again -- even if you knew the
> final product MUST be delivered in C++ due to contractual
> requirements, you'd STILL be better off doing the early phases
> in Python ANYWAY.  Once the program is working, benchmark it;
> most often, you'll find you're done -- in a FRACTION of the
> time.  If the performance isn't satisfactory, profile it, and
> start optimizing -- including recoding parts in C++, e.g.
> with weave or the Boost Python Library.  In the end, you'll use
> both Python and C++ in the same program, *each for what it does
> best*: Python for most of the code, C++ for the bottlenecks.
> It's as simple as this, really!
> 
> And your programming productivity will soar...
> 
> 
> Alex




More information about the Python-list mailing list