Switching to Python

Though BASH has served my scripting needs for many years, I’m finding the various limitations of the language quite frustrating. For example, just last week, I was trying to do some string processing. I know this should be trivial to someone who knows cut, sed and and other textutils, but that someone isn’t me. The various types of quotes, no spaces before equal signs for declaring variables and other subtle details kept slowing me down.

It was time for a real language.

I’ve tried countless times before to bring python into my set of everyday skills. Two major issues kept taking me back into the world of bash:

  • The use of indentation for logic. When I write C/C++/Java code, I hardly look at the screen. I just go on typing code (like writing poetry) and then press C-c C-q to auto-indent the current region. At the same time I press C-c C-c to start compilation within emacs so that I can look at compilation errors right in the edit window. It’s only after the above two steps that I actually look at what I’ve written. The use of curly braces is part of my thought process.

  • Poor support for python out-of-the-box in emacs. Pressing Tab doesn’t take you to the right level of indentation (maybe because there isn’t a “right” level of indentation?) This has drastically improved in recent versions.

On the other hand, it wasn’t very smart to ignore something with so many potential advantages. In my few days with python, I was amazed to see the breadth and quality of the available libraries. All the way from web frameworks, numerical libraries, scientific plotting, imaging, MPI and distributed libraries to even parsing C++ code. There are also wrappers for almost every imaginable C/C++ library out there (ITK, VTK, ODE, SDL, …)

I decided to go cold turkey and port one of my glue scripts at my day job from bash to python. Once I had gotten over my initial wall of skepticism, I found the ride easy and actually enjoyable. Ofcourse, every time I hit a road block, google has always come to the rescue. I haven’t learnt to use any of the advanced feature of python yet, but I’m sufficiently satisfied with my progress thus far.

I’ll be detailing my experiences with python in the next few weeks.

Possibly related:

One Response to “Switching to Python”

  1. IA-64, IA-32, x86_64 » Ganesh Swami Says:

    [...] Ganesh Swami Quick brown foxes and lazy dogs. « Switching to Python [...]

Leave a Reply