Does Python 'enable' poke and hope programming?

CM cmpython at gmail.com
Thu Aug 1 13:57:07 EDT 2013


(My subject line is meant to be tongue and cheek inflammatory)

I've been thinking about why programming for me often feels like ice skating uphill.  I think part of the problem, maybe the biggest part, is what now strikes me as a Very Bad Habit, which is "poke and hope" (trial and error) programming (of several names this page provided, I kind of like that one):

http://en.wikipedia.org/wiki/Programming_by_permutation

It seems that if I can make a change to the code and then immediately test it by running the Python interpreter and finding out, in a few seconds, if it worked, I am going to be *much* more likely to use this trial-and-error approach than if I had to use a compiled language, since compiling takes so long.  E.g. "Oh, that doesn't work?  Maybe if I add this...no.  OK, what about if I increment that?  No...OK, wait, maybe this...AH!  That worked."  (obviously it is not quite that uninformed all the time).

Instead, with a compiled language, because of the pain of having to wait for the newest version to compile, one would be encouraged to get the mechanism of how something works *clear* and robustly represented in one's mind (or on scrap paper/notes document) prior to testing through compiling and running.

Basically this amounts to:  with an interpreted language (so of course this is not really just about Python--I just think in terms of Python), it's easier to be mentally lazy.  But, ironically, being lazy winds up creating *way* more work ultimately, since one winds up programming in this terribly inefficient way, and progress proceeds at an, at times, evolutionary (slow!) pace.

And of course I am not really blaming it on Python or any interpreted language; I am blaming it fully on my own lame habits and attitude.

I'm sick of this in my own work, and want to avoid this trap as much as I can from now on.

Thoughts?





More information about the Python-list mailing list