On Python Present and Perl Past

I’ve been working in Python almost exclusively for the last 8 or 9 months. It’s been a fun challenge learning a new language, and being able to do it along with the rest of the We Also Walk Dogs crew has made it even better. A dip back into Perl has given me a chance to reflect on my progress with Python.

The past couple weekends I’ve been helping a friend with a small project – a textual analysis problem finding similarities between disparate documents in a large database. I immediately reached for Perl because I’ve done projects like this in Perl before and I knew all the tools I’d need. I indexed phrases from the docs using Digest::MD5, storing the index in MySQL with DBD::mysql. Then I whipped up a quick web-app with CGI::Application and HTML::Template, with a bit of help from HTML::FillinForm, Blueprint CSS and Config::General. With the exception of Blueprint (which I find indispensable these days), this is pretty much the toolkit I learned (and helped build) at Vanguard Media working for Jesse Erlbaum over ten years ago! It all worked great and the app was up and running in just a day and a half.

This experience makes it obvious to me that I still have a long way to go with Python. Perl syntax is second nature to me – I almost never make an error and everything works the way I expect it to. I’m not looking up basic Python syntax anymore but I am still making plenty of mistakes. More to the point, the tools I needed to use for this project are all still completely ingrained in my memory, and behave exactly the way I expect them to. Compared to the Python tools I use daily (Django, Celery and MySQLdb, for example), the difference is really impressive. My Python tools often surprise me and I find myself going back to the docs, and failing that the source, frequently.

It’s also interesting to think about how little has changed in the past 10 years. I can pick up the same tools I used then and construct something that most people would recognize as a modern web app. Mix in just a little Jquery and it would probably pass for Web 2.0. On the other hand, I think I can say I’ve gotten better as I’ve aged – this project would have taken me quite a bit longer 10 years ago, if I could have completed it at all. I probably would have gotten stuck on some completely insane plan like loading all the documents into memory at once. I really didn’t know how to properly use a database back then!

I am looking forward to making my first open-source Python release soon. Who knows, maybe there’s a book about writing Python packages for PyPi in my future!

You may also like


  1. Textual analysis problem sounds awesome. Curious to hear more if there’s more to say.

    Ditto on how much a few years’ experience can change your coding. When I started I spent a lot of time reinventing wheels or working on needlessly frilly or impossible schemes, and I just had no concept at all that you need to be able to read and maintain code, not just run it. I still get hung up on things or write confusing code sometimes, but I’ve improved…a little…I hope. :)

    It’s also interesting to me how the gotchas we run into on our Python and Perl projects are pretty different from each other — Python the language actually seems easier to me, and I like some of these framework features, but we seem to run into more surprises and inflexible bits in our Python tools. (Everyone’s mileage probably varies.) Maybe I’ll rant about it some other time.

  2. Er, and I don’t want to shortchange the Python tools — like you implied in the post, I think a big chunk of our Python frustrations just come from being n00bs at coding in this environment.

  3. Everytime I try Python I always get stuck on it’s scoping rules. I’m just so addicted to the lexical scoping of Lisp and Perl. But I guess I have the same problem with Javascript too, but I make do. That’s probably because I have to use Javascript, but still. I should really Python another chance or two.

  4. @Michael Peters Yup – it’s all about being forced to use a new language. It’s mighty hard to get out of the Perl comfort zone by choice. I didn’t choose to use Python for ActionKit but I’m glad we’re doing it.

  5. @Randall Farmer Yeah, I might post more about the project when it’s done. Not sure how much exposure is ok with my friend. I agree that it’s been surprising how different coding in Perl and Python can be – on the surface the languages seem so similar but the actual usage in the wider community is so different.

  6. @sam tregar, that helps a lot. I would like any feedback you have on docs, APIs etc.

    I feel I use help(obj)/dir(obj) as much in Python, as I used perldoc in Perl. Most times the Python REPL saves me from looking at the source, where in Perl I always had my “vimod Module::Name” script nearby. Have to admit, there was a lot to hate for me in the beginning writing Python, but now I love almost everything I used to hate about it.

    Still, I really miss CPAN, and Moose has some really neat stuff, makes Python OOP almost as bare bones as Perl’s.

  7. Ask: FWIW, take a look at Perl::Shell. It installs a “perlcmd” that is intentionally identical (or gradually approaching it anyway) to the Python REPL :)

  8. Dear Sam Tregar,

    Sorry if I sound offensive. I really used perl and python for almost 7 years. I get bad words when people praise python.

    The reason is:

    1) python is slower than perl for most tasks. Even if u speed it up using modules, there are perl alternatives there too. Nobody really cares about increasing speed for every program. Also, let me know where is unladen swallow going?

    2) You can write clean, legible code in perl too.

    3) Python OOP is not so good. Ruby has best OOP. Perl Moose is better than python OOP.

    4) Too many half-baked python frameworks. But, I shud accept that SQLAlchemy is the best ORM of any language. Pylons is a good web framework among all python web frameworks.

    5) Though python has modules in wider application areas, the total number of them is lesser than CPAN by atleast 2000 percent. (20X lesser modules). For these areas you can interface best tools for job with perl. (Example “R” statistical project)

    6) Perl Catalyst is really cool framework. It improved a lot in the last 2 years.

    7) U can do anything with perl but not the same with python easily. Take for example, many unsuccessful graphics projects for 3D. We did lot of 3D graphics with Perl + OpenGL and have satisfied customers.

    Perl 6 syntax is much cleaner than perl 5. I am not worried about release getting late , since I can do most tasks with perl 5.X series. Till such time, python revises OOP, takes care of speed and includes functional programming modules I will use it less often.

    How one sees things matters most. If one finds python good, he shud use it! But shudn’t advise that others are not having this or that….Only this made me offensive and write about python in a bit negative way.


  9. @thota
    I’m confused – did you read my post? It was about how I was happy to come back to Perl and find that I’m still so much more productive in it than I am in Python. How is that a diss on Perl?

Leave a Reply

Your email address will not be published. Required fields are marked *