Object Relational Mappers are evil (a meditation)

J Kenneth King james at agentultra.com
Wed Dec 23 10:55:19 EST 2009


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:

> On Mon, 21 Dec 2009 11:44:29 -0500, J Kenneth King wrote:
>
>> A programmer that
>> lacks critical thinking is a bad programmer.  The language they use has
>> no bearing on such human facilities.
>
> That's nonsense, and I can demonstrate it by reference to a single 
> programming language, namely Python.
>
> For many years, Python had no ternary if operator:
>
> result = x if condition else y 
>
> Instead the accepted, idiomatic Python way of writing this was to use 
> short-circuit booleans:
>
> result = condition and x or y
>
> However this idiom is buggy! If x is a false-value (say, 0) then result 
> gets set to y no matter what the value of condition.
>
> This buggy idiom survived many years of Python development, missed by 
> virtually everyone. Even coders of the calibre of Raymond Hettinger (who 
> neither lacks critical thinking nor is a bad programmer) have been bitten 
> by this:
>
> "The construct can be error-prone.  When an error occurs it can be
> invisible to the person who wrote it.  I got bitten in published code
> that had survived testing and code review: ..."
>
> http://mail.python.org/pipermail/python-dev/2005-September/056510.html
>
>
> This is a clear and obvious case where a language feature (in this case, 
> the lack of a feature) encouraged an otherwise excellent coder to make an 
> error. It was a very subtle error, which was not picked up by the author, 
> the tests, or the coder reviewer(s). Had Python been different (either by 
> including a ternary if statement, or by forcing and/or to return bools 
> only) then this bug never would have occurred.
>
> Of course awful programmers will be awful programmers in any language, 
> and excellent programmers will be excellent programmers in many languages.
>
> (I say "many" rather than any deliberately. There's a reason why nobody 
> uses languages like Brainf*ck, Whitespace, Ook or Intercal for real work.)
>
> But most coders are neither awful nor excellent. The language DOES make a 
> difference: the quality of a technician depends partly on the quality of 
> his tools, and programmers are no different.
>
> If you don't believe me, imagine writing code in a language without 
> functions or loops, so you have to use GOTO for everything.

All very true.

But did the lack of ternary encourage Raymond to become a bad
programmer?

That is what I believe the core of the argument is.  Sure the misfeature
was over-looked by Raymond, but it took him (and perhaps the help of
others) to recognize it and fix it. That's because he's human and the
language is inert. He is smart and obviously has the cognitive
capabilities to recognize that the language has to change in order to be
a better tool.

It would be a different story if he just assumed that the misfeature was
actually a feature and that it was a good thing. In such a case would
Python the language be at fault or the people who write programs with
it?

Good tools make all the difference in the world, I'm not arguing that.

Just that the tools don't use us; we use them.  Programming in Python
doesn't instantly make me a better programmer.  It can certainly make me
think of myself as a good programmer though... ;)



More information about the Python-list mailing list