convince me

Opus opus at value.net
Tue Aug 6 02:23:30 EDT 2002


>From one who cut his teeth on C, it is simple and straight forward.  
Untill you start dealing with pointers to pointers, and handeling all 
that is special about (char *) and casts, and malloc (what?  out of 
space???).  So much of all software is the same.  So much so that I 
believe that the best bet for doing anything is to use the most top 
level language that one knows, and then work down from there.

I for one, am not about to drag out C/C++ to write a window interface 
for a simple little program.  I would do it in something simple and 
sweet.  (Do you want to program playing with the event loop?)

The confusing part about many top level languages is that there 
really are so many different ways to solve a specific problem.  Some 
of them are MUCH better than others.  This can be because of the 
algorithm or because of not using the right approach in the language. 
 One such discussion on this was on this list a few weeks back where 
there was discussion about converting a list of numbers into a string 
representation of their ASCII representation.  For just 255 values, 
thy took from 1.6 seconds to 0.14 seconds (Python 2.2, Win2K, PIII-
450).  The fast one used a tool in Python to do it.

The trick with any language is to know the tools, and what their 
costs are.  Like using a hashed data structure (Python = dictionary) 
requires using a hash function.  This will slow things down because 
there is an extra step, but because you can find a value by it's key, 
and not have to search for it, it may actually improve the speed of 
the code.

Improved algorithms can amount for seriously improved performance.  
While playing with a way to generate some prime numbers I came upon 
the Sieve of Eratosthenes.  This seriously improved performance over 
the brute force method.  Go check it out on your own, and try your 
hand at generating the first 1000 primes.  

Now, all that being said, the wonderful thing about Python seems to 
be that one can integrate C (or any language) code into your Python 
project.  So, if you find that you really do need that one part of 
your code optomised it can be done.  

On 6 Aug 2002 at 0:36, Peter Hansen wrote:

> Siegfried Gonzi wrote:
> > 
> [ in response to suggestions to hold off learning C in favour of Python]
> > Have to beg differ. I once red a comment (I think it was in a German
> > newsgroup) from a 42 old developer (who wanted just to become a hobby
> > programmer on Linux) that he found it much more straightforward to
> > program in C than in Python. Note he was at that time a beginner and
> > searched for help a few weeks ago in that specific newsgroup whether he
> > should learn C or Python or Perl or Pascal or ... He wrote that
> > everything in C makes sense to him.
> > 
> > I did not follow the comments in the following but the post surprised me
> > that one finds C more easily to grasp than Python, especially when he is
> > a novice in programming.
> 
> I've met people like this.  Without exception, they have been old hands
> at hardware, and understand things like bytes and clock cycles and such,
> but they know next to nothing about software.  Most of the time they even
> seem to find Assembly attractive, but what after all is C but Assembly 
> with braces?  :)
> 
> -Peter
> -- 
> http://mail.python.org/mailman/listinfo/python-list


--Opus--

If ignorance is bliss, why don't I work with happy people.
                            - Unknown

--------------------------------------------------------
Get added to my Humor list:
mailto:opus at value.net?subject=ADD_HUMOR
Get added to my Neat list:
mailto:opus at value.net?subject=ADD_NEAT
Get my PGP public key:
mailto:opus at value.net?subject=PSEND&body=send%20PublicKEY.asc
Visit My Home Page:
http://value.net/~opus/







More information about the Python-list mailing list