[ale] Python questions

Michael D. Hirsch mhirsch at nubridges.com
Wed Aug 4 10:27:49 EDT 2004


On Tuesday 03 August 2004 10:37 pm, James P. Kinney III wrote:
> On Tue, 2004-08-03 at 21:41, Chris Fowler wrote:
> > I'm looking at writing some of our code in python so I can have some
> > true OOP goodness.  I've built the latest and installed it but am having
> > issues getting started.  For starters I'm use to the perl module
> > system.  If I need a module I'll go get it with CPAN.  With python I
> > have to download it from one of many sites and manually build and
> > install.  I'm having difficulty getting the MySQL module to compile
> > because of my unique setup on my machine.  Is there a better way? Should
> > I just use OOP the best I can in Perl and forget the python?

Check out the "Vautlts of Parnassus" http://www.vex.net/parnassus/.  It is not 
as easy and complete as CPAN, but you can find pretty much every Python 
library there.

> > What would be the benefit of Python over Perl for writing basically
> > scripts that do everything.  My programs are the backend agents for a
> > J2EE application.  The gather data, notify technicians, etc.  J2EE is
> > only used for the presentation of that data.
>
> Almost flamebait...   :)
>
> There seem to be two completely different mindsets between perl and
> python. The "there's more than one way to do it" from perl give a huge
> amount of freedom to the developer at the expense of cryptic code to
> debug later. Python requires some very rigid coding constraints
> (whitespace counts is the first one to encounter) that can make for more
> readable code later. But the module base in perl is much larger.

I would phrase this same idea somewhat differently.  Perl almost encourages 
obfuscated code in that it is very easy to write code that is difficult to 
understand a few months later.  Python syntax is much more readable--you have 
to work hard to write hard to follow code.  Please note that I am not 
claiming you can't write clean perl code or obfuscated Python code.

Python is fully object oriented, whereas perl's objects are more a coding 
convention.  If you want objects and are not already addicted to perl, Python 
is probably a better bet.

For one-off scripts perl can't be beat.  For entire systems that need long 
term maintenance, Python would be my choice.  It sounds to me like your needs 
lie right in the middle of these two extremes.

You say you are working in a J2EE application.  I can understand not wanting 
to use Java for these things--Java can be clunky for scripty stuff.  On the 
other hand, once you are in a JVM it is nice to stay there.  You might enjoy 
checking out a couple of the hundred or so Java scripting languages.  I 
recommend looking at Jython (Python in a JVM--all the advantages of Python 
inside the JVM) or Groovy (Java-like syntax, but still a scripting language).

Alternatively, you might check out Ruby.  It seems very popular with the 
hackish crowd.  It is even more OO than Python (which is more OO than Java), 
but it has a more perlish syntax.  

Michael



More information about the Ale mailing list