Why should I use python if I can use java

Kemp Randy-W18971 Randy.L.Kemp at motorola.com
Thu Jun 7 09:06:05 EDT 2001

Well said, and I agree.  Java has it's place and Python has it's place.  And we have talked about EJB in these lists, along with open source, but is everyone aware that four strong open source, ejb movements exist?
So far, in my experience, jboss is ahead of the game, and all the above do have one thing in common with Python: They are all open source.  Python is cool!  Java is Cool!  You just need to know when to use each.  I wouldn't drive a boat on the Chicago freeway, or a motorcycle on Lake Michigan. 

-----Original Message-----
From: Geoffrey Gerrietts [mailto:geoff at homegain.com]
Sent: Wednesday, June 06, 2001 5:32 PM
To: python-list at python.org
Subject: RE: Why should i use python if i can use java

mik <karmen2001 at HOTMAIL.COM> asks:
> i' m a python newbie but I've this prob. i have seen Jython ..
> what has python dat java does not?????????

As someone who just recently spent a lot of time on this group explaining
Java's benefits, I think my karma may demand something of an about face. I
can't tell you what you'll like best about Python, or what you'll use most,
but I can tell you how things have worked for me.

I think it can be summed up in a sentence: Python is a lot more flexible
than Java. That doesn't mean that you can do some things in Python that you
can't in Java; it just means that some things are much easier to do in
Python than in Java. I might go so far as to say most things.

Reflection in Java is a pain in my ass. It's inconvenient and it's pretty
difficult to get at the actual methods or properties to call them. Python
makes that very simple, to the point of trivial. Python makes it very easy
to grab hold of what you want when you want it. It's a lot easier for me to
write components that can accomodate any object at all without relying on
whether standard interfaces have been implemented. It's also very easy to
manipulate functions or methods, copy them between objects, or otherwise
manipulate the results of my introspection.

Unit-testing under Python is a lot easier, or has proven so for me. Because
you have almost total control over the objects you import and use, you can
stick in "stubs" for standard library components, so that your "stub"
returns standardized values. You can also do it for user-contributed

Prototyping and experimenting is easier under Python, too. I slap together a
few lines of code into a file, then python -i <filename> -- the Python
interpreter runs my lines, then gives me a command prompt, so I can
experiment with the data, try various combinations of function calls, or
otherwise validate my work.

In Python, I know how to write classes whose instances are other classes. In
Python, I know how to write a routine that generates a string of python
code, then executes the contents of the string. These are highly dynamic
features that I don't know how to exploit in Java, if it's even practical to
do so. Note that you /can/ do it in Java, but it may take you ten or twenty
or a thousand lines of Java to do what one or two or five lines of Python do
quite easily.

These are all features I can say that I've used in Python -- used the hell
out of some of them. They lack in Java, or are more difficult to access.

Geoff Gerrietts <geoff at homegain.com>
Software Engineer, HomeGain.com
510-655-0800 x4320

More information about the Python-list mailing list