Defending the ternary operator
adalke at mindspring.com
Sat Feb 8 22:00:57 CET 2003
> Why do you lack such faith in programmers? Python is the programmer's
> friend, not the programmer's keeper.
I've been thinking about that viewpoint, since you first suggested it
to me. I don't think it's a lack of faith. Rather, it's the experience
the more flexible the language the more likely it is that dialect will
emerge that make it harder to share and understand others' code.
I have seen it happen in Perl. I have seen it happen in C++. I would
rather limit it from happening in Python.
As such, Python is the programming community's friend, and not
simply the single programmer's friend.
> What trauma you have suffered at
> the hands of inferior code should not blind you. Beautiful code is
> something that is nurtured and *created*.
There's something to be said for beauty. But beauty is not additive.
Bake a pie from the best ingredients using the best oven and you
can still end up with a mess. (Okay, that's a Heinlein reference :)
> You cannot attain it by
> forming an environment where all bad techniques are outlawed, based on
> the expectation that given no other options the bad programmer will
> somehow write beautiful code. It would be like taking a cast of a
> beautiful orchid, then seeding a ragweed beneath the cast. The ragweed
> will not become an orchid simply because no other shape is allowed it.
But you can make square watermelons that way. ;)
Orchids live in wild, wet, verdant jungles. Outside of their natural
environment, orchids live in carefully tended hothouses. (As I recall.
I am no horticulturalist.)
Taking your analogy futher, does that mean that everything should
be jumbled together (the jungle) so that orchid might live naturally?
Or that we should have highly controlled environment, so that they
might live elsewhere?
Laura does not propose that all bad techniques are outlawed. After
all, "a FORTRAN programmer can write FORTRAN code in
any language". She pointed out that people will use if/else expression
in the interest of saving a few keystrokes, rather than promote
readability, which should be a primary goal of good software
And that's a view I enjoy as well. I've seen people do it, and
seen the confusion it sows.
> Ugly code can be thrown away. That task is easy. Our efforts should
> focus on the beautiful code, because that is the difficult task and the
> worthwhile task. We should judge this extension to the language with
> our aspiration, not with our fears.
Ugly code can not be thrown away if it is useful. It can be replaced.
There are some who will work and work to make the most elegant
code. There's the story of the programmer who will stare and stare
at code to make it smaller and tighter. "I am done not when I have
nothing to add but when I have nothing more to remove."
I am not one of those people. I am happy with my good-looking
code. It pays the job, and it doesn't have the upkeep like some
beautiful wom^H^H^Hcode have. And I get along better with
my clients and friends than rewriting everything for beauty.
dalke at dalkescientific.com
More information about the Python-list