Friday, November 11, 2011

"P"erl versus "P"ython

Capital "P" programmers everywhere are making the switch from Perl to Python for scripting. Like many, I've resisted the change. I mean, c'mon, you cannot dictate how I structure my source code. Free form is dangerous but allows the flexibility to be elegant or not. HA! Moving into a new job, I thought it might be a good time to give Python a true chance to live in my research programming environment. I fell in love!!! Once you get past the initial anti-authoritarian, rebellious feelings, it starts to pay off. Not having to think about formatting reminds me of how much I like LaTeX for different but similar reasons. LaTeX does not assume you have the skills of a typesetter, as Word and others do. I just type the content, tag the special bits like "this is a section title" and let the "compiler" do it's thing. Python starts to feel the same way after a while. Why do I need to type a lot of extra characters (braces for blocks, semicolons at the end of the lines, etc) to do simple things like conditional tests and loops? I admit I have not become fully "pythonic" yet (there are many, many cool features in the language beyond straight procedural programs) , but I feel no need to go back to Perl, nor do I feel the need to slam it either. Like MS-DOS, it does work, it has tons of users and it helped me get experience and better appreciate good design. One big selling point for Perl has always been CPAN, the comprehensive perl archive of modules to do everything under the sun. If one needs an algorithm, it's probably already been done in a Perl module on CPAN. It might not the greatest implementation, but good enough to get started. However, Python is catching up VERY quickly, and in fact seems to have more serious attention from professionals. One reason might be that Python code is READABLE, a quality not seen so much in Perl unless effort is taken by the programmer to make it that way. Python code has forced structure that works both functionally and aesthetically. This has many advantages, the biggest one being readability. Perl is notorious for being a write-only language, where the author is the only person who can grok the code! While a language is largely irrelevant when it comes down to it, I feel like Python, when a choice is possible, is my default scripting language.

No comments: