Overcoming the fear of Python January 16, 2008
Posted by xk0der (aka Amit Singh) in : Programming and software development, Random musings , trackbackAs all C, C++ and Perl devotees, I too looked upon Python with apprehension. Python? What? I asked. The very idea of white-spaces being part of syntax gave me jitters and I convulsed with disgust. Why Python? Perl can do it. OOP? Perl has it … errm .. Kind of.
After reading numerous articles about python by putting the search terms “I hate pyton“, “python will die” and the like, I started getting a grasp of differences and likeness between python and other languages. One thing more I learned was, never be judgmental about a programming language if you have not used it. So after traversing threads at various forums related to “Love Python” and “Hate Python” I started understanding the various mumbo-jubo related to python. And then the thought occured to me, let’s give it a try. I downloaded python on my Windows XP machine at home and Vim for windows. Then jumped right into coding a problem that was asked to me in an interview. It was a design problem actually, but nevertheless a design can be implemented
.
Within minutes I was automatically indenting code as I used to with C,C++ or Perl (or other free form languages I had used, for that matter). So the frown over mandatory white-spaces soon turned into a smile. And by the time I could realize I was finished creating a four road junction traffic simulator. I did searched the net for some reference, but the best thing was I just looked at the example and understood what it was, no reading what the code does or will do. Other syntax came so naturally that I didn’t even had to look online. That is I guess the beauty of Python.
In around half an hour or so, I had a complete running program in Python, using classes, random number, lists and other subtle features. The code was so readable, I thought, do I need some of those comments I’ve put in there? Some were required. But most of the time the code was itself very much self-explanatory.
Later I booted my laptop (it has FC7 installed) and copied the code on my Lappy. Python comes bundled with FC7 so I straight-away executed the code. Wow! … Its faster than windows .. Ha ha … yes this is what I noticed. Then I tinkered a bit more with the code, optimizing some things and learning new stuff in the process. Overall I enjoyed my first step into Python, very much.
I’m not going to shun C,C++ or Perl for that matter. For quick one-liners Perl is still the best. My domain is embedded systems and Linux Kernel programming so C and C++ are essential. But this discovery about Python has really give me an option. Option to create large and manageable programs in less time. They say in the python community, You spend more time solving the problem as you code and less time worrying about the language and its syntax. I Agree!
Like this post?
Comments»
I have had similar experiences with Python. It’s an interesting language. The one thing that concerns me is version 3 - apparently quite a break from the syntax used before (and perhaps a bit closer to modern languages such as C#).
It always puzzled me why some methods were static on Python instead of methods of objects - so I’m wondering if that has been addressed in v.3
[...] I?m not going to shun C,C++ or Perl for that matter. For quick one-liners Perl is still the best. My domain is embedded systems and Linux Kernel programming so C and C++ are essential. But this discovery about Python has really give me … read more [...]
Jonathan wrote:
“The one thing that concerns me is version 3 - apparently quite a break from the syntax used before (and perhaps a bit closer to modern languages such as C#).”
Um, no. Python 3’s *syntax* is so close to Python 2.x’s syntax as to be almost indistinguishable (the “print” statement becomes a “print()” function, for example, and that’s one of the *big* differences). If someone told you otherwise, they were misinformed or trying to misinform you.
“It always puzzled me why some methods were static on Python instead of methods of objects”
I’ve often wondered why people feel that a callable *must* always be a method and never a “first-class” function. There’s nothing whatsoever about object-oriented programming which requires this (OOP simply requires that everything be an object and be able to be treated as such, a requirement Python has met since day 1), so I really do wonder where this idea comes from.
Just to add to the cascade of “me too” comments that I’m sure this post will generate, I also use to think that the whitespacing in Python would be wretched, but now I wish all programming languages supported it. It finally ended the frivolous-but-unending holy war of “opening curly brace on the same line or next line”.
I wrote about programming language judgment and Python in particular in my blog post, Is It Possible at All to Discuss Language Wars without Starting One?
http://coffeeghost.net/2008/03/22/is-it-possible-at-all-to-discuss-language-wars-without-starting-one/
I am having a hard time installing python modules or even psyco (python’s code optimizer) i get a huge bunch of errors - that I just give up later.
[...] Another devotee to the non-church of Python [...]