Python Module: nift

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Feb 8 16:34:50 EST 2009


Gabriel Genellina:
> bearophile:
> > - Generally I suggest to learn to code in the small, using as little
> > code as possible.
>
> I completely agree with all the above suggestions, except this last one.  
> Ok, I think I know what you mean, but a beginner might understand this  
> completely wrong. Readability is important, and trying to compress too  
> much code into one single line should not be the ultimate goal.

What I meant is to use less code as possible, keeping readability and
the original flexibility.

I can't stress enough the importance of writing less code. Every new
programmer has to learn how much important it is. Less code means less
bugs, less lines to edit and debug, etc. Less code is usually more
elegant, and often more readable (even if you take 3 times to read
each line it may be good anyway if you have 1/10 of the lines of code.
Recently in the "Java to Python" thread someone has posted some Java
class that is scary, you can probably write the same thing in
1/10-1/20 of the lines of code).

The sense for "elegance" in coding is of course (as in every other
human activity) something you learn after many years of exercise, it's
a matter of balance among many opposite things, a matter of
compromises, and it's also tight related with your personal style of
coding. Every programmer develops tastes and and one or more styles,
that other people may not appreciate much.

Bye,
bearophile



More information about the Python-list mailing list