Steve Holden wrote: [was Python-list digest, Vol 1 #10572 - 14 msgs]

Michael Gilfix mgilfix at eecs.tufts.edu
Sat Apr 27 14:20:25 EDT 2002


On Sat, Apr 27 @ 20:07, Roman Neuhauser wrote:
>     I disagree entirely.
> 
>     When I write code @work, I think "if 'x' is equal to 0", because
>     one of my colleagues couldn't wrap his head around the safe way.
>     When I write my own code, I think "if 0 is equal to 'x'". No, wait,
>     I don't know what I think: the thought is abstract, and can be
>     written both ways. But I actually have to remember to put the
>     variable on the left, and the constant on the right side.

  For me, it works the other way around. If I'm programming in an
imperative paradigm, my thought process is sequential. I'm usually at
state A and want to get to state B and in the imperative paradigm,
my program is the list of steps to get from A to B.  Therefore,
logically, it makes sense to think of x == '0' because by deduction,
sometime earlier x must have been declared and assigned to and this is
a pre-step to 0.

  I'm sure most people find it more intuitive to put to the
left at any rate. Hence the reason it's a common bug among
newbies-intermediaries and even careless experts. However, your
thinking that you write " if 'x' is equal to 0" because your
colleagues won't understand only serves to re-enforce my point.

> >   Python is smart to avoid such assignments...
> 
>     Python thinks I'm too dumb to take care of myself.

  Big projects get complicated quickly. Especially if you're working
in an environment where you have many different developers of varying
skills and backgrounds. From a pure software engineering perspective
and even a cost perspective, it's desirable to eliminate all sources
of error - especially if they don't limit the expressiveness of the
language. Otherwise, why not just program in perl? Perl will let you
do *anything* you so desire. But then, why does everyone complain Perl
is completely unmaintainable? I've worked on maintaining a large Perl
code base and yes, it can be done, provided the people who code have
good style and produce clear code. But in a constantly changing
environment (what's the average - people switch jobs every 1 or 2
years in CS), nevermind one of differing skills, I'd rather not
leave that up to chance.

               -- Mike

-- 
Michael Gilfix
mgilfix at eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html





More information about the Python-list mailing list