Why Python?

Here’s a question I get sometimes: why did we use Python? I had been programming in J2EE/Java for six years
before ProjectPipe. I had used most of the major technology areas in J2EE: ejb, servlet, jsp, jms, etc. I had
lead several successful projects that mostly used BEA’s WebLogic app server (for a while it was the best J2EE app server),
though I also used the JBoss/Tomcat combination as well (mostly during development because it was faster to reboot).

We’re not the only people who have left J2EE for hopefully greener pastures. Bruce Eckel just wrote
an article about people leaving Java for Ruby.
I left Java for Python. I left for two reasons: 1) my buddy Mike bugged me to look into Python and 2) once
I got over the white space/indentation Python issue, I found my productivity is higher. It’s difficult to compare
your productivity when using two different technologies, because once you solve a problem using one technology,
you’ve learned some things and it’s easier to solve the same problem in a different technology. Anyway, the only
concrete difference I can offer is that it used to take about a minute to boot up a J2EE app server, but I can boot up
my Python app server in 2 seconds. If you consider that during development you might reboot a hundred times in a day
(you usually don’t have to reboot in either technology if you just change a web page), then you can see that you might
lose 6000 sec (100 x 60 sec) or 100 minutes using J2EE vs. 200 sec (100 x 2 sec) using Python. Of course, when your
app server is rebooting you might look over code, but on the other hand it’s very distracting to wait an entire minute
before you can test changes you just made — you’re just as likely to keep surfing the web an extra ten minutes while
waiting for your app server to finish booting up. And since J2EE is so damn complicated, it’s tough to write unit tests
– I’ve done it occasionally in J2EE, but you usually have to either test outside of J2EE or go to the trouble of
setting up and using the Cactus testing framework. If you write
tests using Cactus, you’re still stuck with your app server boot time.

The Python community has a number of database and web frameworks available, but Mike and I chose
Twisted for our networking and Nevow
for our web framework. We rolled our own database support (written on top of Twisted). Mike was the
instigator to use Twisted — it took a while to convince stubborn me to use it, but after looking around, I grew
comfortable because the guys developing it are really smart, and their arguments on the simplicity and scalability
of their async approach sold me.

I would say that the only major thing I miss from Java is the boost in performance you get with Java’s excellent
JIT (Just In Time) compilers that come with the JVM. A while ago in an old weblog of mine,
I made some simple performance measurements
and found that Java with JIT is something like an order of magnitude faster than Python. Though I’m keeping my
eye out on the PyPy project which is working on JIT technologies
for Python (which is especially difficult because of the dynamic nature of the language).

Comments are closed.