Wednesday, January 16, 2008

Motivation

So where do we begin? Well with how this blog came about...

I have been thinking about writing some of this stuff down for some time, but a few recent Python related posts have motivated me to getting out and having my say on the matter. A few weeks back was this XKCD cartoon
which probably sums up how us enthusiasts feel about the language.
Welcome to our world, Randall.

But just yesterday I noticed this entry that said Knuth had suggested using indentation for program structure many years ago. Since one of the perennial bugbears that arises in Python advocacy is the use of significant whitespace, having DEK's seal of approval puts the final nail in the coffin of the naysayers. The Knuth books have been a source of information and inspiration to me for many years and I have pored over every line and worked through most of the exercises in search of a mistake (motivated by the desire to score one of the checks). I did find one mistake a few years ago but I had been beaten to the punch by a few months as it turned out. I did manage to get a $0.32 'valuable suggestion' check last year by solving one of the problems in a new and different way, and Python was instrumental here. More on that sometime in the future, it is a good story and demonstration of the power of the language.

The bottom line is: suck it and see. The use of whitespace indentation
for structure is elegant. You will get used to it. ESR did along with many others.

I won't go over the interminable arguments that are raised against whitespace structure. For me, the indentation makes code readable and unambiguous. It just works (for me anyway). End of story. And as I said in the previous entry, for an old FORTRAN user, it never was an issue.


The indentation works as does the language as a whole. (Again, for meanyway). This may be related to the sort of engineering/scientificproblems I tackle and the environment in which I work. The librariessupplied with Python cover just about everything I need and it is easy tofill in the gaps. Speed is never an issue: for number crunching onhomogeneous arrays we have Numpy, and if there is anything which can't bemodelled there, swig is your friend. Or ctypes. The possibilities are endless.

Anyway, I digress. Seeing the whitespace issue raised yet again just made me feel it would probably be worth putting in my $.02 worth. So here we are.

So enough motivation and advocacy for the time being. I'll try and address some interesting problems that I have solved efficiently using Python. The sort of problems of interest to an engineer/scientist working with real world issues. I have yet to find any real reason to become au-fait with closures, functional programming and a lot of the other topics that get discussed in some of these forums (forii?) Python may or may not handle these but it is certainly good for useful (to me) stuff.

No comments: