Plain Python

Perl is cool, much more so than Python. But I prefer writing Python.

Perl is fun to read about. It has an endless stream of features to discover. Python by comparison is kinda dull. But the aspects of a language that make it fun to read about do not necessarily make it pleasant to use.

I wrote Perl off and on for several years before trying Python. People would tell me I should try Python and every six months or so I’d skim through a Python book. My impression was that Python was prosaic. It didn’t seem to offer any advantage over Perl, so I stuck with Perl. (Not that I was ever very good at Perl.)

Then I read an article by Bruce Eckel saying that he liked Python because he could remember the syntax. He said that despite teaching Java and writing books on Java, he could never remember the syntax for opening a file in Java, for example. But he could remember the corresponding Python syntax. I would never have picked up on that by skimming books. You’ve got to actually use a language a while to know how memorable the syntax is. But  I had used Perl enough to know that I could not remember its syntax without frequent use. Memorable syntax increases productivity. You don’t have to break your train of thought as often to reach for a reference book.

I stand by my initial impression that Python is plain, but I now think that’s a strength. It just gets out of my way and lets me get my work done. I’m sure  Perl gurus can be extremely productive in Perl. I tried being a Perl guru, and I never made it. I wouldn’t say I’m a Python guru, but I also don’t feel the need to be a guru to use Python.

Python code is not cool in a line-by-line sense, not in the way that an awesomely powerful Perl one-liner is cool. Python is cool in more subtle ways.

Related posts

18 thoughts on “Plain Python

  1. > But he could remember the corresponding Python syntax.

    This is a big part of what makes Python “fun” for me… I can focus on the task, and less on the tool (or language). Other languages may be more powerful/complex/expressive/etc., but I find the challenge to be in solving the problem at hand, not in adding an extra level of difficulty by using a language that is more effort by nature.

    All of this is of course due to the fact that Python is not my primary language, so I am not immersed in it on a daily basis (SQL is), and Python takes (me) a little less effort to get restarted in.

  2. I started using Python in early 2000. There were a variety of features that attracted me to it. But I stuck with it because it was so easy to remember. I was working as a systems architect – and only got to write code about eight hours a week. I found that a year after writing a small app, program or utility I could pick it up right away with minimal re-learning time.

    I think this is just one of many beneficial results from some of the pythonic philosophies – like one right way of doing things. Another big one is that the learning curve is so short. On one huge project I chose python and was the only one that knew it previously. Over the years we trained a dozen people in python – and it was so easy to do that there was never any formal training.

    Anyhow, glad to hear someone else articulate this aspect of python.

  3. Brendan O'Connor

    Not the same for ruby. I stopped using python for ~1.5 years and it was very easy to pick back up. But if I stop using ruby for a few months, it can be nontrivial to refresh. It’s a more complex language with odd conventions that make it harder to use at a low cognitive load (e.g. opening classes).

    Some things in ruby are brilliantly designed and very easy to pick back up, like map/select/etc block chaining. but overall it’s harder.

  4. But isn’t the same true for ruby? ;)

    I am biased because I do use ruby since 5 years, have NO problem with python though – but I came from perl and php background. I found perl had too many weaknesses – the syntax was less elegant than python and ruby, and perl failed to conquer the www (which I personally think was the only reason why php really was a big success – their www focus).

    Maybe perl 6 can change this one day, but for now it still seems to be a duke nukem forever story with perl, right next to GNU Hurd….

  5. As someone who has been trying to make the same switch, I have to say, I keep returning to Perl because I keep forgetting the Python syntax!

    I don’t think it’s a failing of Python, it’s mostly due to my lack of using it long enough to recall the operators and methods by heart. But if that’s the case, then pretty much any language can be comfortably familiar, provided you put in the legwork to use it enough to learn it. The real question is, what language has the most memorable syntax in terms of the duration of time required to become efficient from recall only?

    I can’t claim any insight into that; I learned Perl to get by in my job. 60-hour per week exposure is way more Python than I’ll ever be writing recreationally.

    Still, to each his own. And you’re dead on about Java being infinitely forgettable.

  6. “Memorable syntax increases productivity. You don’t have to break your train of thought as often to reach for a reference book.”

    I find it increases the rate at which I can write lines of code, for this reason. That doesn’t necessarily correlate with productivity, especially long-term productivity.

    In Common Lisp, for example, I can never remember all the args to with-open-file (though I can remember the couple I use all the time, and Emacs can tell me the rest). But my programs end up naturally OAOO. If I need something for a purpose other than how I coded it, I rarely have to refactor to use it. It’s already in a data structure I can use.

    In Python, I can crank out the lines of code faster, but then after a month I have … a lot of lines of code. Then I have to go back and refactor, especially when I want to use something in a different way than originally intended.

    I wonder if there’s a way to build a system with the best of both worlds. There’s got to be something better than Common Lisp for memorization, while keeping its benefits.

  7. Abhishek Ghose

    Was delighted to know that I am not the only one who has a hard time remembering syntax to open files in Java :) I am a Rubyist, but I am planning to shortly look at Python because of its alleged performance edge over Ruby (I say ‘alleged’ since I am yet to see a conclusive comparison of Python with Ruby 1.9)

  8. I love Perl. I use Perl. I have never really wanted to do Python and I think I am still in that camp. However, this post is very to the point.

  9. Python is the easiest language to use and to remember the syntax. I can concentrate 100% in the task and the tool does not bother me. Also Another cool features that Python borrowed are from Haskell a very interesting programming language thast kick the arse of antother programming languages.

  10. Python makes me feel that anything is do-able. The biggest plus for me was that Python made me want to write my code in an object oriented way. With Perl all I had were hundreds of lines in a single script. With python, once my code gets too big I immediately think of creating objects and having them do the work. Perl never did nudge me in this direction.

  11. This post seems to resonate much with (and, in a way, summarize) Eric S. Raymond’s “Why Python?“. It’s much longer, but worth reading. That post delivered the final blow in convincing me to give up my plan to learn Perl (no matter how much I liked working with regex) and try Python instead.

  12. I am not CS student but I need to write code for my research. C/C++ is powerful with its high speed but it’s very difficult to learn for me. The first time I met Python, I was very surprised how quick I could learn it. Thanks for your article.

  13. I followed the same path with Python. Was a Perl code for several years, I dipped my toe into the Python pool a few times but never waded in. Then I was asked to teach a course in computing and thought since teaching is the best way to learn, I taught in Python and was amazed at how much easier it was do many things in Python as compared to Perl or C. And for tasks that require OOP, Python is head and shoulders above Perl.

  14. I used several programming languages such as Assembly, Pascal, Delphi,Visual Basic, Matlab, C++, Fortran etc for a long time but recently I am experiencing Python. When I need to produce a nice look GUI rich application the best for me is Visual Basic yet. For me all experience with python GUI producers were not good enough. If I want to evaluate a numerical algorithm with immediate graphics and of course with enjoyment I use Python. When I need to improve the computation speed I use Fortran to generate library to be used in Python.

  15. I was just thinking last night, this is why I miss Pascal.

    I don’t mind lots of extra typing either, because if the code is readable I save time reading/writing comments.

    People new to programming assume WRITING the code is time-consuming, but thinking through the problem is typically where you’re burning the most calories. Not saving a few keystrokes.

    Anyway, I agree with the above comment about PHP’s popularity due to its “www” birthright, but please don’t hate on PHP because you have a Ruby syntax fetish ;-) Too many programmers get hung up on the craft and forget the raison d’etre.

Comments are closed.